Edit report at http://bugs.php.net/bug.php?id=52872&edit=1

 ID:                 52872
 Updated by:         ras...@php.net
 Reported by:        ndesbarats at gmail dot com
 Summary:            Basic math operation returns incorrect result
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Windows 7
 PHP Version:        5.3.3
 Block user comment: N

 New Comment:

Floating point values have a limited precision. Hence a value might 
not have the same string representation after any processing. That also
includes writing a floating point value in your script and directly 
printing it without any mathematical operations.

If you would like to know more about "floats" and what IEEE
754 is, read this:
http://docs.sun.com/source/806-3568/ncg_goldberg.html
 
Thank you for your interest in PHP.

.


Previous Comments:
------------------------------------------------------------------------
[2010-09-17 16:43:27] ndesbarats at gmail dot com

Description:
------------
See test script below.

Test script:
---------------
<?php



$num = 123456.123456;



echo 'remainder: '.($num - (integer)$num).'<br />';



// remainder should be 0.123456

// instead, I get a remainder of 0.12345600000117 (!!!!!!!)



?>

Expected result:
----------------
// remainder should be 0.123456



Actual result:
--------------
// instead, I get a remainder of 0.12345600000117 (!!!!!!!)


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52872&edit=1

Reply via email to