Integer



Integer inherits from Number and defines no instance variables. It has subclasses LongInteger and SmallInteger.

Integers are the subset of real numbers that can be obtained by successively adding 1 or -1 to 0.

The VM operates with essentially two kinds of integers: SmallIntegers, which can range from -16384 to 16383, and LongIntegers, which can range from approx -2.1 billion to 2.1 billion.

SmallIntegers are encoded directly as immediate values and therefore take no space in heap memory.

LongIntegers are encoded as byte-indexable objects with 4 bytes each.

Arithmetic operations will automatically convert between SmallIntegers and LongIntegers as necessary, but overflowing the range of LongIntegers will cause "wrapping" of results---the same as in C and other languages.

In other words, it is not possible to have integers of a magnitude larger than about 2.1 billion without implementing some kind of LargeInteger class.

Methods defined in Integer:

Methods for accessing:

Methods for arithmetic:

Methods for bit manipulation:

Methods for comparing:

Methods for converting:

Methods for double dispatching:

Methods for flow control:

Methods for math functions:

Methods for predicates:

Methods for printing:


Pocket Smalltalk Documentation