Category: Language-Data types
Superclass: LargeInteger
Just like my brother LargeNegativeInteger, I provide a few methods that allow LargeInteger to determine the sign of a large integer in a fast way during its calculations. For example, I know that I am larger than any LargeNegativeInteger. In addition I implement the guts of arbitrary precision arithmetic.

Method category index

arithmetic (instance)
converting (instance)
helper byte-level methods (instance)
numeric testing (instance)
primitive operations (instance)

arithmetic (instance)

+ aNumber
Sum the receiver and aNumber, answer the result

- aNumber

Subtract aNumber from the receiver, answer the result

gcd: anInteger

Calculate the GCD between the receiver and anInteger

highBit

Answer the receiver's highest bit's index

top


converting (instance)

asFloatD
Answer the receiver converted to a FloatD

asFloatE

Answer the receiver converted to a FloatE

asFloatQ

Answer the receiver converted to a FloatQ

replace: str withStringBase: radix

Return in a String str the base radix representation of the receiver.

top


helper byte-level methods (instance)

bytes: byteArray1 from: j compare: byteArray2
Private - Answer the sign of byteArray2 - byteArray1; the j-th byte of byteArray1 is compared with the first of byteArray2, the j+1-th with the second, and so on.

bytes: byteArray1 from: j subtract: byteArray2

Private - Sutract the bytes in byteArray2 from those in byteArray1

bytes: bytes multiply: anInteger

Private - Multiply the bytes in bytes by anInteger, which must be < 255. Put the result back in bytes.

bytesLeftShift: aByteArray

Private - Left shift by 1 place the bytes in aByteArray

bytesLeftShift: aByteArray big: totalShift

Private - Left shift the bytes in aByteArray by totalShift places

bytesLeftShift: aByteArray n: shift

Private - Left shift by shift places the bytes in aByteArray (shift <= 7)

bytesRightShift: aByteArray big: totalShift

Private - Right shift the bytes in aByteArray by totalShift places

bytesRightShift: bytes n: aNumber

Private - Right shift the bytes in `bytes' by 'aNumber' places (shift <= 7)

bytesTrailingZeros: bytes

Private - Answer the number of trailing zero bits in the receiver

primDivide: rhs

Private - Implements Knuth's divide and correct algorithm from `Seminumerical Algorithms' 3rd Edition, section 4.3.1 (which is basically an enhanced version of the divide `algorithm' for two-digit divisors which is taught in primary school!!!)

top


numeric testing (instance)

abs
Answer the receiver's absolute value

negative

Answer whether the receiver is < 0

positive

Answer whether the receiver is >= 0

sign

Answer the receiver's sign

strictlyPositive

Answer whether the receiver is > 0

top


primitive operations (instance)

divide: aNumber using: aBlock
Private - Divide the receiver by aNumber (unsigned division). Evaluate aBlock passing the result ByteArray, the remainder ByteArray, and whether the division had a remainder

isSmall

Private - Answer whether the receiver is small enough to employ simple scalar algorithms for division and multiplication

multiply: aNumber

Private - Multiply the receiver by aNumber (unsigned multiply)

top