|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41733 float substraction doesn't return 0
Submitted: 2007-06-18 23:48 UTC Modified: 2007-06-24 08:02 UTC
From: mc at glouglou dot net Assigned:
Status: Not a bug Package: *Math Functions
PHP Version: 5.2.3 OS: Ubuntu
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: mc at glouglou dot net
New email:
PHP Version: OS:


 [2007-06-18 23:48 UTC] mc at glouglou dot net
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:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-19 05:09 UTC]
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:
Thank you for your interest in PHP.

 [2007-06-24 08:02 UTC] mc at glouglou dot net
Thanks for your answer and the reference.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 17 10:01:28 2024 UTC