php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9692 Subtraction result below 100 yields wrong decimal output
Submitted: 2001-03-12 00:41 UTC Modified: 2001-03-12 16:40 UTC
From: bhavint at directi dot com Assigned:
Status: Closed Package: Math related
PHP Version: 4.0.4pl1 OS: Linux
Private report: No CVE-ID: None
 [2001-03-12 00:41 UTC] bhavint at directi dot com
Please check http://www.transecute.com/~kalpesh/check.php4

In case (1) I subtract a number from another which should output '0.9' but insted outputs '0.90000000000009'

In case (2) I subtract a number from another and it gives correct output

This behaviour has been noticed if the result of the subtraction is greater than 100. I have also published my PHPINFO output on the same page for your reference.

This bug is quite dangerous (especially for us when we are dealing with financial calculations for our payment gateway using PHP) since all our reports dont tally at the end of the day by tiny figures such as this.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-12 00:45 UTC] sniper@php.net
Check the last comment on bug: #9288

--Jani


 [2001-03-12 01:12 UTC] bhavint at directi dot com
i dont think thats the same is it. Because all I am doing is a simple subtraction operation. 

Additionally the output comes perfect if the result is greater than 100 but does not come perfect if the output is lesser than 100
 [2001-03-12 16:40 UTC] sniper@php.net
Yes it is. 
This bug report is about the same 'problem': #8164
And it has an url to a page that explains this better
than I can. :)

--Jani
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 22:01:26 2024 UTC