Bug #74534 [NEW]: 123
| From: | uchihasv at yandex dot ru | Date: | Wed, 03 May 2017 10:56:54 +0000 |
| Subject: | Bug #74534 [NEW]: 123 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-208933@lists.php.net to get a copy of this message | ||
From: uchihasv at yandex dot ru
Operating system: Windows 7 x64
PHP version: 7.1.4
Package: *General Issues
Bug Type: Bug
Bug description:123
Description:
------------
I have array with numbers and i do simple math in loop and in results i
see -6.9388939039072E-17 instead 0
Test script:
---------------
<?php
$h = 0.05;
$x = [-1,-0.5,0,0.5,1];
for($i=0;$i<4;$i++)
{
for($j=$x[$i]+$h;$j<$x[$i+1];$j+=$h)
{
$x2[$i][] = $j;
}
}
echo "<pre>".print_r($x2,1)."</pre>";
Expected result:
----------------
Array
(
[0] => Array
(
[0] => -0.95
[1] => -0.9
[2] => -0.85
[3] => -0.8
[4] => -0.75
[5] => -0.7
[6] => -0.65
[7] => -0.6
[8] => -0.55
)
[1] => Array
(
[0] => -0.45
[1] => -0.4
[2] => -0.35
[3] => -0.3
[4] => -0.25
[5] => -0.2
[6] => -0.15
[7] => -0.1
[8] => -0.05
[9] => 0
)
[2] => Array
(
[0] => 0.05
[1] => 0.1
[2] => 0.15
[3] => 0.2
[4] => 0.25
[5] => 0.3
[6] => 0.35
[7] => 0.4
[8] => 0.45
[9] => 0.5
)
[3] => Array
(
[0] => 0.55
[1] => 0.6
[2] => 0.65
[3] => 0.7
[4] => 0.75
[5] => 0.8
[6] => 0.85
[7] => 0.9
[8] => 0.95
)
)
Actual result:
--------------
Array
(
[0] => Array
(
[0] => -0.95
[1] => -0.9
[2] => -0.85
[3] => -0.8
[4] => -0.75
[5] => -0.7
[6] => -0.65
[7] => -0.6
[8] => -0.55
)
[1] => Array
(
[0] => -0.45
[1] => -0.4
[2] => -0.35
[3] => -0.3
[4] => -0.25
[5] => -0.2
[6] => -0.15
[7] => -0.1
[8] => -0.05
[9] => -6.9388939039072E-17
)
[2] => Array
(
[0] => 0.05
[1] => 0.1
[2] => 0.15
[3] => 0.2
[4] => 0.25
[5] => 0.3
[6] => 0.35
[7] => 0.4
[8] => 0.45
[9] => 0.5
)
[3] => Array
(
[0] => 0.55
[1] => 0.6
[2] => 0.65
[3] => 0.7
[4] => 0.75
[5] => 0.8
[6] => 0.85
[7] => 0.9
[8] => 0.95
)
)
--
Edit bug report at https://bugs.php.net/bug.php?id=74534&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74534&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74534&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74534&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74534&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74534&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74534&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74534&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74534&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74534&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74534&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74534&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74534&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74534&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74534&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74534&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74534&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74534&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74534&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74534&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74534&r=mysqlcfg