|
|
6.82 LargeInteger
- Defined in namespace Smalltalk
- Category: Language-Data types
I represent a large integer, which has to be stored as a long sequence
of bytes. I have methods to do arithmetics and comparisons, but I need
some help from my children, LargePositiveInteger and LargeNegativeInteger,
to speed them up a bit.
6.82.1 LargeInteger: arithmetic
- * aNumber
- Multiply aNumber and the receiver, answer the result
- + aNumber
- Sum the receiver and aNumber, answer the result
- - aNumber
- Sum the receiver and aNumber, answer the result
- / aNumber
- Divide aNumber and the receiver, answer the result (an Integer or Fraction)
- // aNumber
- Divide aNumber and the receiver, answer the result truncated towards -infinity
- \\ aNumber
- Divide aNumber and the receiver, answer the remainder truncated towards -infinity
- estimatedLog
- Answer an estimate of (self abs floorLog: 10)
- negated
- Answer the receiver's negated
- quo: aNumber
- Divide aNumber and the receiver, answer the result truncated towards 0
- rem: aNumber
- Divide aNumber and the receiver, answer the remainder truncated towards 0
6.82.2 LargeInteger: bit operations
- bitAnd: aNumber
- Answer the receiver ANDed with aNumber
- bitAt: aNumber
- Answer the aNumber-th bit in the receiver, where the LSB is 1
- bitInvert
- Answer the receiver's 1's complement
- bitOr: aNumber
- Answer the receiver ORed with aNumber
- bitShift: aNumber
- Answer the receiver shifted by aNumber places
- bitXor: aNumber
- Answer the receiver XORed with aNumber
6.82.3 LargeInteger: built-ins
- at: anIndex
- Answer the anIndex-th byte in the receiver's representation
- at: anIndex put: aNumber
- Answer the anIndex-th byte in the receiver's representation
- digitAt: anIndex
- Answer the anIndex-th base-256 digit in the receiver's representation
- digitAt: anIndex put: aNumber
- Answer the anIndex-th base-256 digit in the receiver's representation
- digitLength
- Answer the number of base-256 digits in the receiver
- hash
- Answer an hash value for the receiver
- primReplaceFrom: start to: stop with: replacementString
- startingAt: replaceStart
Private - Replace the characters from start to stop with new characters contained in replacementString (which, actually, can be any variable byte class, starting at the replaceStart location of replacementString
- size
- Answer the number of indexed instance variable in the receiver
6.82.4 LargeInteger: coercion
- coerce: aNumber
- Truncate the number; if needed, convert it to LargeInteger representation.
- generality
- Answer the receiver's generality
- unity
- Coerce 1 to the receiver's class
- zero
- Coerce 0 to the receiver's class
6.82.5 LargeInteger: disabled
- asObject
- This method always fails. The number of OOPs is far less than the minimum number represented with a LargeInteger.
- asObjectNoFail
- Answer `nil'.
6.82.6 LargeInteger: primitive operations
- basicLeftShift: totalShift
- Private - Left shift the receiver by aNumber places
- basicRightShift: totalShift
- Private - Right shift the receiver by 'shift' places
- largeNegated
- Private - Same as negated, but always answer a LargeInteger
6.82.7 LargeInteger: testing
- < aNumber
- Answer whether the receiver is smaller than aNumber
- <= aNumber
- Answer whether the receiver is smaller than aNumber or equal to it
- = aNumber
- Answer whether the receiver and aNumber identify the same number
- > aNumber
- Answer whether the receiver is greater than aNumber
- >= aNumber
- Answer whether the receiver is greater than aNumber or equal to it
- ~= aNumber
- Answer whether the receiver and aNumber identify the same number
|