Category: Language-Data types
Superclass: Number
I am the abstract integer class of the GNU Smalltalk system. My subclasses' instances can represent signed integers of various sizes (a subclass is picked according to the size), with varying efficiency.

Method category index

converting (class)
accessing (instance)
basic (instance)
bit operators (instance)
converting (instance)
extension (instance)
iterators (instance)
math methods (instance)
printing (instance)
storing (instance)
testing functionality (instance)

converting (class)

coerce: aNumber
Answer aNumber converted to a kind of Integer

top


accessing (instance)

denominator
Answer `1'.

numerator

Answer the receiver.

top


basic (instance)

hash
Answer an hash value for the receiver

top


bit operators (instance)

allMask: anInteger
True if all 1 bits in anInteger are 1 in the receiver

anyMask: anInteger

True if any 1 bits in anInteger are 1 in the receiver

bitAt: index

Answer the index-th bit of the receiver (the LSB has an index of 1)

bitAt: index put: value

Answer an integer which is identical to the receiver, possibly with the exception of the index-th bit of the receiver (the LSB having an index of 1), which assumes a value equal to the low-order bit of the second parameter.

bitClear: aMask

Answer an Integer equal to the receiver, except that all the bits that are set in aMask are cleared.

bitInvert

Return the 1's complement of the bits of the receiver

clearBit: index

Clear the index-th bit of the receiver and answer a new Integer

digitAt: index

Answer the index-th base-256 digit of the receiver (byte), expressed in two's complement

highBit

Return the index of the highest order 1 bit of the receiver.

isBitSet: index

Answer whether the index-th bit of the receiver is set

lowBit

Return the index of the lowest order 1 bit of the receiver.

noMask: anInteger

Answer true if no 1 bits in anInteger are 1 in the receiver.

setBit: index

Set the index-th bit of the receiver and answer a new Integer

top


converting (instance)

asCharacter
Return self as a Character or UnicodeCharacter object.

asFraction

Return the receiver converted to a fraction

asScaledDecimal: n

Answer the receiver, converted to a ScaledDecimal object. The scale is forced to be 0.

ceiling

Return the receiver - it's already truncated

coerce: aNumber

Coerce aNumber to the receiver's class.

floor

Return the receiver - it's already truncated

rounded

Return the receiver - it's already truncated

truncated

Return the receiver - it's already truncated

top


extension (instance)

alignTo: anInteger
Answer the receiver, truncated to the first higher or equal multiple of anInteger (which must be a power of two)

top


iterators (instance)

timesRepeat: aBlock
Evaluate aBlock a number of times equal to the receiver's value. Compiled in-line for no argument aBlocks without temporaries, and therefore not overridable.

top


math methods (instance)

binomial: anInteger
Compute the number of combinations of anInteger objects among a number of objects given by the receiver.

ceilingLog: radix

Answer (self log: radix) ceiling. Optimized to answer an integer.

estimatedLog

Answer an estimate of (self abs floorLog: 10)

even

Return whether the receiver is even

factorial

Return the receiver's factorial.

floorLog: radix

Answer (self log: radix) floor. Optimized to answer an integer.

gcd: anInteger

Return the greatest common divisor (Euclid's algorithm) between the receiver and anInteger

lcm: anInteger

Return the least common multiple between the receiver and anInteger

odd

Return whether the receiver is odd

top


printing (instance)

displayOn: aStream
Print on aStream the base 10 representation of the receiver

displayString

Return the base 10 representation of the receiver

isLiteralObject

Answer whether the receiver is expressible as a Smalltalk literal.

printOn: aStream

Print on aStream the base 10 representation of the receiver

printOn: aStream base: b

Print on aStream the base b representation of the receiver

printOn: aStream paddedWith: padding to: size

Print on aStream the base 10 representation of the receiver, padded if necessary to size characters with copies of padding.

printOn: aStream paddedWith: padding to: size base: baseInteger

Print on aStream the base b representation of the receiver, padded if necessary to size characters with copies of padding.

printPaddedWith: padding to: size

Return the base baseInteger representation of the receiver, padded if necessary to size characters with copies of padding.

printPaddedWith: padding to: size base: baseInteger

Return the base baseInteger representation of the receiver, padded if necessary to size characters with copies of padding.

printString

Return the base 10 representation of the receiver

printString: baseInteger

Return the base baseInteger representation of the receiver

printStringRadix: baseInteger

Return the base baseInteger representation of the receiver, with BBr in front of it

radix: baseInteger

Return the base baseInteger representation of the receiver, with BBr in front of it. This method is deprecated, use #printStringRadix: instead.

storeLiteralOn: aStream

Store on aStream some Smalltalk code which compiles to the receiver

storeOn: aStream base: b

Print on aStream Smalltalk code compiling to the receiver, represented in base b

top


storing (instance)

storeOn: aStream
Print on aStream the base 10 representation of the receiver

storeString

Return the base 10 representation of the receiver

top


testing functionality (instance)

isInteger
Answer `true'.

isRational

Answer whether the receiver is rational - true

top