Back: LargeByteArray-overridden Up: Base classes Forward: LargeInteger-accessing   Top: GNU Smalltalk Library Reference Contents: Table of Contents Index: Class index About: About this document

1.96 LargeInteger

Defined in namespace Smalltalk
Superclass: Integer
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.

1.96.1 LargeInteger: accessing  (instance)
1.96.2 LargeInteger: arithmetic  (instance)
1.96.3 LargeInteger: bit operations  (instance)
1.96.4 LargeInteger: built-ins  (instance)
1.96.5 LargeInteger: coercion  (instance)
1.96.6 LargeInteger: disabled  (instance)
1.96.7 LargeInteger: primitive operations  (instance)
1.96.8 LargeInteger: testing  (instance)


1.96.1 LargeInteger: accessing

raisedToInteger: n
Return self raised to the anInteger-th power


1.96.2 LargeInteger: arithmetic

* aNumber
Multiply aNumber and the receiver, answer the result

+ aNumber
Sum the receiver and aNumber, answer the result

- aNumber
Subtract aNumber from the receiver, 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

divExact: aNumber
Dividing receiver by arg assuming that the remainder is zero, and answer the result

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


1.96.3 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

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


1.96.4 LargeInteger: built-ins

at: anIndex
Answer the anIndex-th byte in the receiver's representation

at: anIndex put: aNumber
Set the anIndex-th byte in the receiver's representation

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

digitAt: anIndex put: aNumber
Set 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


1.96.5 LargeInteger: coercion

asCNumber
Convert the receiver to a kind of number that is understood by the C call-out mechanism.

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


1.96.6 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'.


1.96.7 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


1.96.8 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 different numbers.



Back: LargeInteger-primitive operations Up: LargeInteger Forward: LargeNegativeInteger   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