php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45300 Bug in number format
Submitted: 2008-06-18 12:50 UTC Modified: 2008-07-01 09:54 UTC
Votes:2
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: gernovich at ya dot ru Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.2.6 OS: win xp
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gernovich at ya dot ru
New email:
PHP Version: OS:

 

 [2008-06-18 12:50 UTC] gernovich at ya dot ru
Description:
------------
Convertion problem with float types.
The problem is also affected on round() and ceil(),
but number_format() not no mathematical function.

Reproduce code:
---------------
$a = -0.014;
print round($a,1)."\n"; // -0 bogus
print number_format($a, 1)."\n"; // -0.0 bug

Expected result:
----------------
-0
0.0


Actual result:
--------------
-0
-0.0


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-07-01 09:54 UTC] jani@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-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 19 05:00:03 2025 UTC