bug 43053 - scientific notation
| From: | Ryan Brothers | Date: | Thu, 13 Mar 2008 16:03:00 +0000 |
| Subject: | bug 43053 - scientific notation | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-36123@lists.php.net to get a copy of this message | ||
Hello,
I just wanted to find out the status of bug 43053
(http://bugs.php.net/bug.php?id=43053) which is regarding inconsistent
handling of floating point numbers which seems to have changed in PHP 5.2.2
and later, but I don't see it documented nor see it listed on any changelog
or announcement. The problem is that certain floating point numbers are
being printed in scientific notation while others aren't - for example,
1200000.00 prints as 1.2E+6 while 1300000.00 prints as 1300000. In PHP
5.2.1 and earlier, 1200000.00 printed as 1200000. This then causes output
and validation issues since if the 1.2E+6 number is being passed somewhere
else, sprintf must be wrapped around it (e.g. echo'ed in the script, put in
a xml document validated against a schema, etc).
While I understand that the way floating point numbers are stored can vary
and shouldn't be relied upon, I'm more curious why a change was made in PHP
5.2.2 to print certain numbers in scientific notation, as it makes working
with floating point numbers much more difficult in PHP - in all previous
versions of PHP, these numbers were printed out in full form, not in
scientific notation.
Appreciate any help or feedback you could provide-
Thanks,
Ryan