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