Integer Arithmetic By default, Perl assumes that it must do most of its arithmetic in floating point. But by saying use integer; you may tell the compiler to use integer operations (see integer for a detailed explanation) from here to the end of the enclosing BLOCK. An inner BLOCK may countermand this by saying no integer; which lasts until the end of that BLOCK. Note that this doesn't mean everything is an integer, merely that Perl will use integer operations for arithmetic, comparison, and bitwise operators. For example, even under "use integer", if you take the sqrt(2), you'll still get 1.4142135623731 or so. Used on numbers, the bitwise operators ("&" "|" "^" "~" "<<" ">>") always produce integral results. (But see also "Bitwise String Operators".) However, "use integer" still has meaning for them. By default, their results are interpreted as unsigned integers, but if "use integer" is in effect, their results are interpreted as signed integers. For example, "~0" usually evaluates to a large integral value. However, "use integer; ~0" is -1 on two's-complement machines. Floating-point Arithmetic While "use integer" provides integer-only arithmetic, there is no analogous mechanism to provide automatic rounding or truncation to a certain number of decimal places. For rounding to a certain number of digits, "sprintf()" or "printf()" is usually the easiest route. See perlfaq4. Floating-point numbers are only approximations to what a mathematician would call real numbers. There are infinitely more reals than floats, so some corners must be cut. For example: printf "%.20g\n", 123456789123456789; # produces 123456789123456784 Testing for exact floating-point equality or inequality is not a good idea. Here's a (relatively expensive) work-around to compare whether two floating-point numbers are equal to a particular number of decimal places. See Knuth, volume II, for a more robust treatment of this topic. sub fp_equal { my ($X, $Y, $POINTS) = @_; my ($tX, $tY); $tX = sprintf("%.${POINTS}g", $X); $tY = sprintf("%.${POINTS}g", $Y); return $tX eq $tY; } The POSIX module (part of the standard perl distribution) implements "ceil()", "floor()", and other mathematical and trigonometric functions. The "Math::Complex" module (part of the standard perl distribution) defines mathematical functions that work on both the reals and the imaginary numbers. "Math::Complex" is not as efficient as POSIX, but POSIX can't work with complex numbers. Rounding in financial applications can have serious implications, and the rounding method used should be specified precisely. In these cases, it probably pays not to trust whichever system rounding is being used by Perl, but to instead implement the rounding function you need yourself. Bigger Numbers The standard "Math::BigInt", "Math::BigRat", and "Math::BigFloat" modules, along with the "bignum", "bigint", and "bigrat" pragmas, provide variable-precision arithmetic and overloaded operators, although they're currently pretty slow. At the cost of some space and considerable speed, they avoid the normal pitfalls associated with limited-precision representations. use 5.010; use bigint; # easy interface to Math::BigInt $x = 123456789123456789; say $x * $x; +15241578780673678515622620750190521 Or with rationals: use 5.010; use bigrat; $x = 3/22; $y = 4/6; say "x/y is ", $x/$y; say "x*y is ", $x*$y; x/y is 9/44 x*y is 1/11 Several modules let you calculate with unlimited or fixed precision (bound only by memory and CPU time). There are also some non-standard modules that provide faster implementations via external C libraries. Here is a short, but incomplete summary: Math::String treat string sequences like numbers Math::FixedPrecision calculate with a fixed precision Math::Currency for currency calculations Bit::Vector manipulate bit vectors fast (uses C) Math::BigIntFast Bit::Vector wrapper for big numbers Math::Pari provides access to the Pari C library Math::Cephes uses the external Cephes C library (no big numbers) Math::Cephes::Fraction fractions via the Cephes library Math::GMP another one using an external C library Math::GMPz an alternative interface to libgmp's big ints Math::GMPq an interface to libgmp's fraction numbers Math::GMPf an interface to libgmp's floating point numbers Choose wisely. POD ERRORS Hey! The above document had some coding errors, which are explained below: Around line 3: You forgot a '=back' before '=head2' Around line 129: =back without =over