Integers
Factor handbook > The language > Numbers

Prev:Converting between numbers and strings
Next:Rational numbers


integer


Integers come in two varieties -- fixnums and bignums. Fixnums fit in a machine word and are faster to manipulate; if the result of a fixnum operation is too large to fit in a fixnum, the result is upgraded to a bignum. Here is an example where two fixnums are multiplied yielding a bignum:
USE: classes 67108864 class-of .
fixnum

USE: classes 128 class-of .
fixnum

134217728 128 * .
17179869184

USE: classes 1 128 shift class-of .
bignum

Integers can be entered using a different base; see Number syntax.

Integers can be tested for, and real numbers can be converted to integers:
fixnum? ( object -- ? )

bignum? ( object -- ? )

>fixnum ( x -- n )

>integer ( x -- n )

>bignum ( x -- n )


See also
Prettyprinting numbers, Modular arithmetic, Bitwise arithmetic, Integer functions, Integer syntax