The stupid question is the question not asked | |
PerlMonks |
Re: How does Perl handle arithmetic overflows?by dave_the_m (Monsignor) |
on Sep 08, 2016 at 10:56 UTC ( [id://1171386]=note: print w/replies, xml ) | Need Help?? |
Internally, perl changes the data type of variables where necessary/possible in arithmetic to try to avoid loss of precision and/or overflow. So for example on a typical 64-bit system, repeated $x += 1 will cause the internal type to change from being initially a signed 64-bit int, to an unsigned 64-bit, and finally to a double - at which point it doesn't overflow, but may lose precision.
The exact details of what types are used at what points depends on the platform. Dave.
In Section
Seekers of Perl Wisdom
|
|