Req #66866 [NEW]: Same output for float numbers when using variable handling functions
From: jan dot kahoun at heureka dot cz
Operating system: CentOS release 6.4 (Final)
PHP version: Irrelevant
Package: Variables related
Bug Type: Feature/Change Request
Bug description:Same output for float numbers when using variable handling functions
Description:
------------
I know that the floating point values have a limited precision and hence
a value might not have the same string representation after any
processing. But it is possible to make var_dump(), print_r() and
var_export() functions to output same result for float numbers? Some
times the different output results leads to hard debuging ;-)
If this is not possible, please mention this "feature" in the
documentation of the functions.
Thank you.
Test script:
---------------
$x = 0.399999999999999855671006798729649744927883148193359375;
print_r($x);
var_export($x);
var_dump($x);
Expected result:
----------------
Same result for all functions:
print_r() = 0.399999999999999855671006798729649744927883148193359375
var_export() = 0.399999999999999855671006798729649744927883148193359375
var_dump() =
float(0.399999999999999855671006798729649744927883148193359375)
Actual result:
--------------
print_r() = 0.4
var_export() = 0.399999999999999855671006798729649744927883148193359375
var_dump() = float(0.4)
--
Edit bug report at https://bugs.php.net/bug.php?id=66866&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66866&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66866&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66866&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66866&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66866&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66866&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66866&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66866&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66866&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66866&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66866&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66866&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66866&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66866&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66866&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66866&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66866&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66866&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66866&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66866&r=mysqlcfg
Thread (1 message)
- jan dot kahoun at heureka dot cz