This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[win32] merge changes#872,873 from maintbranch
[perl5.git] / lib / integer.pm
CommitLineData
a0d0e21e
LW
1package integer;
2
f06db76b
AD
3=head1 NAME
4
5integer - Perl pragma to compute arithmetic in integer instead of double
6
7=head1 SYNOPSIS
8
9 use integer;
10 $x = 10/3;
11 # $x is now 3, not 3.33333333333333333
12
13=head1 DESCRIPTION
14
a3cb178b 15This tells the compiler to use integer operations
f06db76b
AD
16from here to the end of the enclosing BLOCK. On many machines,
17this doesn't matter a great deal for most computations, but on those
18without floating point hardware, it can make a big difference.
19
a3cb178b
GS
20Note that this affects the operations, not the numbers. If you run this
21code
22
23 use integer;
24 $x = 1.5;
25 $y = $x + 1;
26 $z = -1.5;
27
28you'll be left with C<$x == 1.5>, C<$y == 2> and C<$z == -1>. The $z
29case happens because unary C<-> counts as an operation.
30
f06db76b
AD
31See L<perlmod/Pragmatic Modules>.
32
33=cut
34
a0d0e21e
LW
35sub import {
36 $^H |= 1;
37}
38
39sub unimport {
40 $^H &= ~1;
41}
42
431;