Bug #68551 [NEW]: filter_var return false for (float) $integer if strlen($integer) > ini_get('precision')

From: Date: Fri, 05 Dec 2014 12:54:17 +0000
Subject: Bug #68551 [NEW]: filter_var return false for (float) $integer if strlen($integer) > ini_get('precision')
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188931@lists.php.net to get a copy of this message
From: frederic dot hardy at mageekbox dot net Operating system: Linux/OSX PHP version: 5.6.3 Package: Filter related Bug Type: Bug Bug description:filter_var return false for (float) $integer if strlen($integer) > ini_get('precision') Description: ------------ filter_var() with option FILTER_VALIDATE_INT return false if its argument is an integer casted to float with strlen($integer) > ini_get('precision'). Test script: --------------- <?php ini_set('precision', 14); // PHP default $i = 12345678912345; // strlen($i) == 14 var_dump(strlen($i)); var_dump(filter_var((float) $i, FILTER_VALIDATE_INT)); // $i var_dump((float) $i == $i); // true $i = 123456789123456; // strlen($i) = 15 var_dump(strlen($i)); var_dump(filter_var((float) $i, FILTER_VALIDATE_INT)); // false instead of $i var_dump((float) $i == $i); // true Expected result: ---------------- int(14) int(12345678912345) bool(true) int(15) bool(123456789123456) bool(true) Actual result: -------------- int(14) int(12345678912345) bool(true) int(15) bool(false) bool(true) -- Edit bug report at https://bugs.php.net/bug.php?id=68551&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68551&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68551&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68551&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=68551&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=68551&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=68551&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=68551&r=needscript Try newer version: https://bugs.php.net/fix.php?id=68551&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=68551&r=support Expected behavior: https://bugs.php.net/fix.php?id=68551&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=68551&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=68551&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=68551&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68551&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=68551&r=dst IIS Stability: https://bugs.php.net/fix.php?id=68551&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=68551&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=68551&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=68551&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=68551&r=mysqlcfg

« previous php.bugs (#188931) next »