ID: 45983
User updated by: ivoras at gmail dot com
-Summary: strval() on float values sometimes gives invalid
output
Reported By: ivoras at gmail dot com
Status: Open
Bug Type: Scripting Engine problem
Operating System: FreeBSD
PHP Version: 5.2.6
New Comment:
Addition to the bug report: I tracked the issue down to the "precision"
setting in php.ini. When set to "4", when strval() receives a number
with 4 digits to the left of the decimal point, the output will only be
a string og 4 digits. E.g. strval(1001.1) returns "1001". The
documentation for "precision" setting says:
"""
precision integer
The number of significant digits displayed in floating point
numbers.
"""
It doesn't mention strval() (and strval() manual page doesn't mention
"precision") and it's a bit ambiguous.
(the behaviour is the same on Linux and FreeBSD).
Previous Comments:
------------------------------------------------------------------------
[2008-09-03 13:32:03] ivoras at gmail dot com
Description:
------------
Calling strval() on certain floating point numbers (not all) on FreeBSD
sometimes inexplicably truncates or rounds the result. Checked on both
FreeBSD 6.3 and 7.0. Works fine in Linux.
Reproduce code:
---------------
<?php
$v = 4867.8;
echo strval($v);
?>
Expected result:
----------------
"4867.8"
Actual result:
--------------
"4867"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45983&edit=1