php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3404 Calculate error
Submitted: 2000-02-04 12:25 UTC Modified: 2000-03-01 14:52 UTC
From: gena at svt dot unity dot net Assigned:
Status: Closed Package: Other
PHP Version: 3.0.14 OS: Linux RH 6.0 (2.2.14)
Private report: No CVE-ID: None
 [2000-02-04 12:25 UTC] gena at svt dot unity dot net
<? 
echo 120 + 2.01 - 121.94; 
//this print 0.070000000000007
?> 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-03-01 14:52 UTC] hholzgra at cvs dot php dot net
this is the old binary/decimal conversion
problem for fractions
<br>
either use printf/sprintf with a format-string
that does not show all decimals, for example
<br>
<?php
printf("%.2f",120 + 2.01 - 121.94);
?>
<br>
will give you only to decimals
<br>
or use the bcmath functions if you really need
the precise values
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 19:01:28 2025 UTC