|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-09-03 13:32 UTC] 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" PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 26 08:00:01 2025 UTC |
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).