Integer documentation

# 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:

- denominator
- numerator

### Methods for arithmetic:

- - number
- * number
- / number
- // number
- \\ number
- + number
- quo: number
- rem: number

### Methods for bit manipulation:

- bitAnd: number
- bitAt: index
- bitOr: number
- bitShift: amount
- bitXor: number

### Methods for comparing:

- ~= number
- < number
- <= number
- = number
- > number
- >= number

### Methods for converting:

- asBoolean
- asDouble
- asFraction
- asInteger
- reduced

### Methods for double dispatching:

- addToFraction: fraction
- coerce: number
  probably never used, since integers are the lowest generality.
- divideIntoFraction: fraction
- divideIntoInteger: integer
- generality
- greaterThanFraction: fraction
- multiplyByFraction: fraction
- subtractFromFraction: fraction

### Methods for flow control:

- timesRepeat: block

### Methods for math functions:

- ceiling
- floor
- gcd: integer

### Methods for predicates:

- even
- isInteger
- odd

### Methods for printing:

- printOn: stream
- printString

Pocket Smalltalk Documentation