php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41152 round()ing HUGE numbers
Submitted: 2007-04-20 17:09 UTC Modified: 2007-04-20 17:46 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: mark at divindedesigns dot ca Assigned:
Status: Not a bug Package: *Math Functions
PHP Version: 5.2.1 OS: linux/windows
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: mark at divindedesigns dot ca
New email:
PHP Version: OS:

 

 [2007-04-20 17:09 UTC] mark at divindedesigns dot ca
Description:
------------
when you round(378240328403284.234) or other large numbers... php automatically translates it with scientific notation... i'm just wondering if we can add that as an option only... say round(#,#,SCIENTIFIC) or whatnot...

i know you can use number_format()... but that's not the intended use of that function.

Reproduce code:
---------------
<?
echo round(324324434324322324.324,2);
?>

Expected result:
----------------
outputs "324324434324322324.32"

Actual result:
--------------
outputs "3.2432443432432E+17"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-20 17:20 UTC] tony2001@php.net
round() doesn't change the number, output depends on the value of "precision" in your php.ini.
 [2007-04-20 17:27 UTC] mark at divindedesigns dot ca
can we change that? these things should be able to be changed on the fly... no?
in my mind... round() should do just that... rounding the number... not be translating with scientific notation... i can see if we make that an option to the round()... some may find that useful... but for the rest of us... having super large numbers being translated on the fly into scientific notation, is just a recipe for disaster...
 [2007-04-20 17:32 UTC] tony2001@php.net
>can we change that?
Use (s)printf() if you want to format the numbers yourself. 

>having super large numbers being translated on the fly into
>scientific notation, is just a recipe for disaster..
What kind of disaster are you talking about?
 [2007-04-20 17:46 UTC] mark at divindedesigns dot ca
say... in a budgeting program(if only i had that much money LOL)... where your expecting numbers to firstly round into nice dollar amounts, then to add up all nice and pretty... well... scientific notation doesnt add up all that nicely...

i know theres work arounds... my complaint isnt that i cant work around it... but that its not working, as it should be... round() should not be translating naturally...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 11:01:30 2024 UTC