5 integer - Perl pragma to compute arithmetic in integer instead of double
11 # $x is now 3, not 3.33333333333333333
15 This tells the compiler to use integer operations
16 from here to the end of the enclosing BLOCK. On many machines,
17 this doesn't matter a great deal for most computations, but on those
18 without floating point hardware, it can make a big difference.
20 Note that this affects the operations, not the numbers. If you run this
28 you'll be left with C<$x == 1.5>, C<$y == 2> and C<$z == -1>. The $z
29 case happens because unary C<-> counts as an operation.
31 Native integer arithmetic (as provided by your C compiler) is used.
32 This means that Perl's own semantics for arithmetic operations may
33 not be preserved. One common source of trouble is the modulus of
34 negative numbers, which Perl does one way, but your hardware may do
37 % perl -le 'print (4 % -3)'
39 % perl -Minteger -le 'print (4 % -3)'
42 See L<perlmod/Pragmatic Modules>.
46 $integer::hint_bits = 0x1;
49 $^H |= $integer::hint_bits;
53 $^H &= ~$integer::hint_bits;