php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46613 55.76 value wrong interpreted
Submitted: 2008-11-19 13:18 UTC Modified: 2008-11-19 13:43 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: nylas2u at yahoo dot com Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 5.2.6 OS: Windows XP
Private report: No CVE-ID: None
 [2008-11-19 13:18 UTC] nylas2u at yahoo dot com
Description:
------------
I have an apache+php+mysql server. If i store in one field this value : 55.76 and after that reapitly decreasing this value to zero, after the las decrease i never can make the value to be zero.

I over verified my script it works in this way with any value like 12.28 even when using 55.76005 but never for 55.76



Reproduce code:
---------------
Example :

55.76 - 10 = 44.76

44.76 - 33 = 11.76

11.76 - 11.76 = 1.17... * E-15


Expected result:
----------------
of course that expected result should be zero


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-19 13:21 UTC] nylas2u at yahoo dot com
I also whant to clarify that the value is tored in an mysql field, and from mysql operation seems to be correct but using php script i have this problem
 [2008-11-19 13:43 UTC] pajoye@php.net
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.


 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Aug 17 10:05:45 2022 UTC