Edit report at https://bugs.php.net/bug.php?id=62959&edit=1
ID: 62959 Updated by: ras...@php.net Reported by: lauris dot kuznecovs at laurisnet dot com Summary: Wrong math -Status: Open +Status: Not a bug Type: Bug Package: Math related Operating System: Windows 7, Centos 5.8 PHP Version: 5.4.6 Block user comment: N Private report: N New Comment: -0 may not exist in traditional math, but it very much exists in computer representations. Computers can't represent floating point values with complete accuracy, so if you manipulate floating point you are going to get rounding errors. -0 means a value rounded to 0 from the negative direction. You can read http://en.wikipedia.org/wiki/Signed_zero for more details. Previous Comments: ------------------------------------------------------------------------ [2012-08-28 17:50:56] lauris dot kuznecovs at laurisnet dot com 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 this bug report at https://bugs.php.net/bug.php?id=62959&edit=1