Integer and Rational Data Types

An integer is a signed whole number: 1, 3, -7.

Some languages allow integers only up to a fixed size, say 32 bits (about +/- 2147483647). Scheme allows integers of any size; the larger ones are sometimes called bignums (short for ``big numbers'').

A rational number is a quotient of two integers: 1, 1/3 . The rationals include the integers as a subset.

Integers and rationals are exact numbers because their values are represented exactly in the computer. Operations on exact numbers produce exact results.

Operations on integers and rationals include: + - * /
- can take one argument or two: (- x) or (- x y).

max maximum of its arguments: (max 3 7) = 7
min minimum of its arguments: (min 3 7) = 3
abs absolute value: (abs -3) = 3
modulo remainder after division: (modulo 7 3) = 1
gcd greatest common divisor: (gcd 42 24) = 6
lcm least common multiple: (lcm 12 15) = 60
expt raises a number to a power: (expt x 3) = x^3.

Contents    Page-10    Prev    Next    Page+10    Index