PHP: various intval() results -


this question has answer here:

i'm beginner php , saw intval() function "returns integer value of var, using specified base conversion".

when consulted official manual http://php.net/manual/en/function.intval.php, gave example follows

echo intval(42);                      // 42   echo intval(4.2);                     // 4   echo intval('42');                    // 42   echo intval('+42');                   // 42   echo intval('-42');                   // -42   echo intval(042);                     // 34   echo intval('042');                   // 42   echo intval(1e10);                    // 1410065408   echo intval('1e10');                  // 1   echo intval(0x1a);                    // 26   echo intval(42000000);                // 42000000   echo intval(420000000000000000000);   // 0   echo intval('420000000000000000000'); // 2147483647   echo intval(42, 8);                   // 42   echo intval('42', 8);                 // 34   echo intval(array());                 // 0   echo intval(array('foo', 'bar'));     // 1   

how did answer of echo intval(1e10); came 1410065408?

this answer explains it: https://stackoverflow.com/a/13720856/2827152

1e10 exceeds maximum integer value can stored, causing overflow.


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

java.util.scanner - How to read and add only numbers to array from a text file -

iphone - Three second countdown in cocos2d -