Back: IdentitySet-testing Up: Base classes Forward: Integer class-converting   Top: GNU Smalltalk Library Reference Contents: Table of Contents Index: Class index About: About this document

1.90 Integer

Defined in namespace Smalltalk
Superclass: Number
Category: Language-Data types
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.

1.90.1 Integer class: converting  (class)
1.90.2 Integer: accessing  (instance)
1.90.3 Integer: basic  (instance)
1.90.4 Integer: bit operators  (instance)
1.90.5 Integer: converting  (instance)
1.90.6 Integer: extension  (instance)
1.90.7 Integer: iterators  (instance)
1.90.8 Integer: math methods  (instance)
1.90.9 Integer: printing  (instance)
1.90.10 Integer: storing  (instance)
1.90.11 Integer: testing functionality  (instance)


1.90.1 Integer class: converting

coerce: aNumber
Answer aNumber converted to a kind of Integer


1.90.2 Integer: accessing

denominator
Answer `1'.

numerator
Answer the receiver.


1.90.3 Integer: basic

hash
Answer an hash value for the receiver


1.90.4 Integer: bit operators

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


1.90.5 Integer: converting

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


1.90.6 Integer: extension

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


1.90.7 Integer: iterators

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.


1.90.8 Integer: math methods

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


1.90.9 Integer: printing

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


1.90.10 Integer: storing

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

storeString
Return the base 10 representation of the receiver


1.90.11 Integer: testing functionality

isInteger
Answer `true'.

isRational
Answer whether the receiver is rational - true



Back: Integer-storing Up: Integer Forward: Interval   Top: GNU Smalltalk Library Reference Contents: Table of Contents Index: Class index About: About this document


This document was generated on August, 19 2010 using texi2html