Bug #62959 [NEW]: Wrong math
| From: | lauris dot kuznecovs at laurisnet dot com | Date: | Tue, 28 Aug 2012 17:50:56 +0000 |
| Subject: | Bug #62959 [NEW]: Wrong math | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-172987@lists.php.net to get a copy of this message | ||
From: lauris dot kuznecovs at laurisnet dot com
Operating system: Windows 7, Centos 5.8
PHP version: 5.4.6
Package: Math related
Bug Type: Bug
Bug description:Wrong math
Description:
------------
<? echo (443.292 - 193.126 - 250.166); ?>
Return: -2.8421709430404e-14
<? echo round(443.292 - 193.126 - 250.166, 2); ?>
Return: -0
But these calculations must return 0.
BTW -0 does not exist in MATH. Maybe some error in rounding function.
Test script:
---------------
<? echo (443.292 - 193.126 - 250.166); ?>
<? echo round(443.292 - 193.126 - 250.166, 2); ?>
Expected result:
----------------
0
--
Edit bug report at https://bugs.php.net/bug.php?id=62959&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=62959&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=62959&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=62959&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=62959&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62959&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=62959&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=62959&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=62959&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=62959&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=62959&r=support
Expected behavior: https://bugs.php.net/fix.php?id=62959&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=62959&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=62959&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=62959&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=62959&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=62959&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=62959&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=62959&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=62959&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=62959&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=62959&r=mysqlcfg