How to enforce Perl create unsigned integer overflows without warnings, e.g. that $a+$b is simply calculated as ($a+$b) modulo 2**64?

Viewed 89

In creating hash functions and larger number arithmetics, it is useful to simply care about the least significant bits and not worry about overflows. I'd need these variables to be treated as unsigned 64-bit variables (machine word architecture) and am expecting correct values $a*$b or $a+$b only in their "least significant 64 bits". In C it would simply be the case, but Perl starts warning of over Infinity, or possibly creates negative values (use integer).

I do not need high precision (BigInt), only the least significant digits, all 64 of them.

(wanted to generate Fibonacci numbers modulo 2**64)

0 Answers
Related