|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26874 round floting number have bad result
Submitted: 2004-01-12 01:48 UTC Modified: 2005-09-22 21:39 UTC
From: yehlu at ms1 dot hinet dot net Assigned:
Status: Not a bug Package: Math related
PHP Version: 4.3.4 OS: linux
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:
15 - 14 = ?
Subscribe to this entry?

 [2004-01-12 01:48 UTC] yehlu at ms1 dot hinet dot net
    $a = 3100;
    echo "\$a :".$a."\n";
    $a *= 1.025;
    echo "\$a * 1.025 :".$a."\n";
    echo "round \$a:".round($a)."\n";  //get 3177
    echo "round \$a:".round("$a")."\n"; //get 3178
    $b = "3177.5";
    echo "\$b:".$b."\n";
    echo "round \$b:".round($b)."\n"; //get 3178


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-12 06:17 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.
Thank you for your interest in PHP.


PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jun 18 12:01:29 2024 UTC