in reply to How does Perl handle arithmetic overflows?

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.

  • Comment on Re: How does Perl handle arithmetic overflows?

Replies are listed 'Best First'.
Re^2: How does Perl handle arithmetic overflows?
by f77coder (Beadle) on Sep 08, 2016 at 12:37 UTC

    Great, thank you.