#41733 [Opn->Bgs]: float substraction doesn't return 0

From: Date: Tue, 19 Jun 2007 05:09:45 +0000
Subject: #41733 [Opn->Bgs]: float substraction doesn't return 0
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-113917@lists.php.net to get a copy of this message
 ID:               41733
 Updated by:       pajoye@php.net
 Reported By:      mc at glouglou dot net
-Status:           Open
+Status:           Bogus
 Bug Type:         *Math Functions
 Operating System: Ubuntu
 PHP Version:      5.2.3
 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:
------------------------------------------------------------------------

[2007-06-18 23:48:42] mc at glouglou dot net

Description:
------------
Came up with this numbers in a web-app.

I've tested this on various platform (Linux/Windows) and PHP version
4.3.9, 5.1, 5.2.1 and 5.2.3 with default php.ini

Reproduce code:
---------------
<?php echo(859-832.35-26.65) ?>

Expected result:
----------------
0

Actual result:
--------------
-2.13162820728E-14


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


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


Thread (3 messages)

« previous php.bugs (#113917) next »