php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30191 sum error
Submitted: 2004-09-22 06:24 UTC Modified: 2004-09-22 08:09 UTC
From: roberto at spadim dot com dot br Assigned:
Status: Not a bug Package: *Math Functions
PHP Version: 5.0.1 OS: linux, windows xp
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: roberto at spadim dot com dot br
New email:
PHP Version: OS:

 

 [2004-09-22 06:24 UTC] roberto at spadim dot com dot br
Description:
------------
sum error: 
590-589.99!=0.01 
	 

Reproduce code:
---------------
<?php
	echo 590-589.99;
	echo "\n";
	echo (double)(590)-(double)(589.99);	
?>

Expected result:
----------------
0.01 
0.01 

Actual result:
--------------
0.0099999999999909 
0.0099999999999909 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-22 08:09 UTC] johannes@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.
 
Thank you for your interest in PHP.

http://www.php.net/manual/en/language.types.float.php 
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Dec 05 13:01:23 2020 UTC