integer overflow

Integer overflow happens when an integer value becomes too large to store as an integer type on the system being used by the script. What PHP will do when this happens is convert the value’s type to double. Keep in mind that, just as the integer type’s magnitude has a limit, the double type’s precision has a limit. Therefore, the value being stored may loose precision.

This is one more reason why you should not assume that a value which was stored as an integer remains an integer.

Note: if you are dealing with extreme number magnitudes (and you want both precision and magnitude to be reflected accurately) then use variable precision numbers. Variable precision numbers are part of PHP; However, I don’t know about them at this time.


About samehramzylabib

See About on
This entry was posted in Coding, PHP Data Value Types, PHP Math and tagged , . Bookmark the permalink.


Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s