diff options
Diffstat (limited to 'contrib/perl5/lib/integer.pm')
-rw-r--r-- | contrib/perl5/lib/integer.pm | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/contrib/perl5/lib/integer.pm b/contrib/perl5/lib/integer.pm index 894931896fc2..86afcaf130db 100644 --- a/contrib/perl5/lib/integer.pm +++ b/contrib/perl5/lib/integer.pm @@ -28,16 +28,29 @@ code you'll be left with C<$x == 1.5>, C<$y == 2> and C<$z == -1>. The $z case happens because unary C<-> counts as an operation. +Native integer arithmetic (as provided by your C compiler) is used. +This means that Perl's own semantics for arithmetic operations may +not be preserved. One common source of trouble is the modulus of +negative numbers, which Perl does one way, but your hardware may do +another. + + % perl -le 'print (4 % -3)' + -2 + % perl -Minteger -le 'print (4 % -3)' + 1 + See L<perlmod/Pragmatic Modules>. =cut +$integer::hint_bits = 0x1; + sub import { - $^H |= 1; + $^H |= $integer::hint_bits; } sub unimport { - $^H &= ~1; + $^H &= ~$integer::hint_bits; } 1; |