php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23866 number_format of 0.x with notation returns -0.00
Submitted: 2003-05-28 16:41 UTC Modified: 2003-05-28 17:20 UTC
From: david at ewebdevelopers dot com Assigned:
Status: Not a bug Package: Math related
PHP Version: 4.3.1 OS: windows 2000
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: david at ewebdevelopers dot com
New email:
PHP Version: OS:

 

 [2003-05-28 16:41 UTC] david at ewebdevelopers dot com
$num = -1.3322676295502E-015;
echo number_format($num, 2, '.', ',');
if(((float) number_format(($num, 2,'.', ',')) == 0){
 echo 'true';
}


number_format should not evaluate to -0.00
should evaluate to 0.00 because there is no such thing as -0;

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-05-28 16:44 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

there is, -0.0000000000000000001E-999 is about -0. Floating points are never precise, -0 is therefore possible.
 [2003-05-28 17:20 UTC] david at ewebdevelopers dot com
This may be true, however when number_format returns -0.00 this is not a valid number.  The evidence that you can use to derive such number is no longer available to you.  When using number_format for display which is the intent of number_format is used for -0.00 is not valid. I realize that the intent of number_format is to format numbers, but I do not think however that it should return numbers that can not possibly exist in the numeric system. Please reconsider your evaluation.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 03:01:28 2024 UTC