From: turgut85 at hotmail dot com
Operating system: Windows XP
PHP version: Irrelevant
PHP Bug Type: Math related
Bug description: Detail
Description:
------------
Is anyone can help me about the code below . Here is I am collecting
values according to increment value between number ranges.
My first example never hits the end point although the end is in range but
second hits the range or third.
Why php treats numbers differently or cannot understand the last value is
still below end point.
Can anyone tell me.
Reproduce code:
---------------
<?PHP
function increment ($start, $end, $increment_val)
{
$ret_arry = array ();
$temp = $start;
if ( ($start+$increment_val) <= $end )
{
do{
echo " " . $temp . "," ;
$temp = $temp + $increment_val;
}while ( $temp <= $end );
}
else
{
echo "Can not do This";
}
}
$start = "1.0";
$end = "1.6";
$increment_val = "0.1";
increment($start, $end, $increment_val);
$start = "1.0";
$end = "4.9";
$increment_val = "0.1";
echo "\n";
increment($start, $end, $increment_val);
?>
Expected result:
----------------
1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6
1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.1, 2.2, 2.3, 2.4,
2.5, 2.6, 2.7, 2.8, 2.9, 3, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9,
4, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9,
Actual result:
--------------
1.0, 1.1, 1.2, 1.3, 1.4, 1.5,
1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.1, 2.2, 2.3, 2.4,
2.5, 2.6, 2.7, 2.8, 2.9, 3, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9,
4, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9,
--
Edit bug report at http://bugs.php.net/?id=26713&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26713&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26713&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=26713&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=26713&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=26713&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=26713&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=26713&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=26713&r=support
Expected behavior: http://bugs.php.net/fix.php?id=26713&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=26713&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=26713&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=26713&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26713&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=26713&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=26713&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=26713&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26713&r=float