|  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
22 + 14 = ?
Subscribe to this entry?

 [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: Thu May 30 21:01:33 2024 UTC