32 bit - PHP intval() changes number NOT 2147483647 -


I am running PHP 5.3.13 and when I execute

  php - R "Echo Infral (99 99 99 99 99);"  

This produces 1410065407.

When I execute

  php -r "echo intval (PHP_INT_MAX);"  

This produces 2147483647.

Why is the small integer causing my code to cause some issues?

In your case, value 9999999999 a name . You can verify it with var_dump (99 99 99 99 99) . When it is placed in signed integer, the value is reduced to 32 bits which gives the value 1410065407 .

You can manually verify this calculation or use the GMP math extension:

  $ num = gmp_init ("9999999999"); $ Beats = GMP_paw (2, 32); Var_dump (gmp_strval (gmp_mod ($ num, $ bits)); // string (10) "1410065407"  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -