Module Interface Object:BigInt

SUMMARY: MODULE | CLASS | TYPE | PROC | VAR | CONST | DETAIL: TYPE | PROC | VAR | CONST

# Object:BigInt

### Import List

        ADT:Storable
        IO
        Object
        Object
        Object:Boxed

Class List
BigInt |

Class Summary: BigInt [Detail]
      +---Object.Object
           |
           +---ADT:Storable.Object
                |
                +---Object:Boxed.Object
                     |
                     +--Object:BigInt.BigInt
Constructor Summary
New(STRING, LONGINT): BigInt
NewInt(LONGINT): BigInt
NewLatin1(ARRAY OF CHAR, LONGINT): BigInt
NewLatin1Region(ARRAY OF CHAR, LONGINT, LONGINT, LONGINT): BigInt
Method Summary
Abs(): BigInt
Add(BigInt): BigInt
Cmp(Object): LONGINT
Copy(): BigInt
Div(BigInt): BigInt
DivMod(BigInt, VAR BigInt, VAR BigInt)
Equals(Object): BOOLEAN Indicates whether some other object is "equal to" this one.
Format(Digit): String8
HashCode(): Hash Returns a hash code value for the object.
Invert(): BigInt Bitwise complement.
IsZero(): BOOLEAN
LShift(LONGINT): BigInt
Load(Reader) Loads data of a from r.
Mod(BigInt): BigInt
Mul(BigInt): BigInt
Neg(): BigInt
NonZero(): BOOLEAN
RShift(LONGINT): BigInt
Sign(): LONGINT
Store(Writer) Stores data of a to w.
Sub(BigInt): BigInt
ToLongInt(): LONGINT
ToString(): String8 Returns a string representation of the object.
Inherited Methods
From Object.Object: Equals, HashCode From ADT:Storable.Object: Load, Store From Object:Boxed.Object: Cmp, ToString

Type Summary
[Digit] = INTEGER
[DigitArray] = POINTER TO ARRAY OF Digit

Variable Summary
one-: BigInt
zero-: BigInt

Class Detail: BigInt

Constructor Detail

### New

    PROCEDURE New(str: STRING;
                  inputBase: LONGINT): BigInt

### NewInt

    PROCEDURE NewInt(int: LONGINT): BigInt

### NewLatin1

    PROCEDURE NewLatin1(str: ARRAY OF CHAR;
                        inputBase: LONGINT): BigInt

### NewLatin1Region

    PROCEDURE NewLatin1Region(str: ARRAY OF CHAR;
                              start: LONGINT;
                              end: LONGINT;
                              inputBase: LONGINT): BigInt

Method Detail

### Abs

    PROCEDURE (a: BigInt) Abs(): BigInt

### Add

    PROCEDURE (a: BigInt) Add(b: BigInt): BigInt

### Cmp

    PROCEDURE (a: BigInt) Cmp(b: Object): LONGINT

> Redefines: Cmp

### Copy

    PROCEDURE (a: BigInt) Copy(): BigInt

### Div

    PROCEDURE (v: BigInt) Div(w: BigInt): BigInt

### DivMod

    PROCEDURE (v: BigInt) DivMod(w: BigInt;
                     VAR div: BigInt;
                     VAR mod: BigInt)

### Equals

    PROCEDURE (a: BigInt) Equals(b: Object): BOOLEAN

> Indicates whether some other object is "equal to" this one.

> The Object.Equals method implements an equivalence relation:

> - It is reflexive: for any reference value ``x`', ``x.Equals(x)`' should return TRUE.

> - It is symmetric: for any reference values ``x`' and ``y`', ``x.Equals(y)`' should return TRUE if and only if ``y.Equals(x)`' returns TRUE.

> - It is transitive: for any reference values ``x`', ``y`', and ``z`', if ``x.Equals(y)`' returns TRUE and ``y.Equals(z)`' returns TRUE, then ``x.Equals(z)`' should return TRUE.

> - It is consistent: for any reference values ``x`' and ``y`', multiple invocations of ``x.Equals(y)`' consistently return TRUE or consistently return FALSE, provided no information used in equals comparisons on the object is modified.

> - For any non-NIL reference value ``x`', ``x.Equals(NIL)`' should return FALSE.

> The ``Equals`' method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any reference values ``x`' and ``y`', this method returns TRUE if and only if ``x`' and ``y`' refer to the same object (``x=y`' has the value TRUE).

> [Description inherited from Equals]

> Redefines: Equals, Equals, Equals

### Format

    PROCEDURE (a: BigInt) Format(outputBase: Digit): String8

### HashCode

    PROCEDURE (a: BigInt) HashCode(): Hash

> Returns a hash code value for the object. This method is supported for the benefit of dictionaries such as those provided by ADT:Dictionary..

> The general contract of Object.HashCode is:

> - Whenever it is invoked on the same object more than once during an execution of an application, the Object.HashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.

> - If two objects are equal according to the Object.Equals method, then calling the Object.HashCode method on each of the two objects must produce the same integer result.

> - It is not required that if two objects are unequal according to the Object.Equals method, then calling the Object.HashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of dictionaries.

> As much as is reasonably practical, the Object.HashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required.)

> [Description inherited from HashCode]

> Redefines: HashCode, HashCode, HashCode

### Invert

    PROCEDURE (a: BigInt) Invert(): BigInt

> Bitwise complement. The result equals ``-(a+1)`'.

### IsZero

    PROCEDURE (a: BigInt) IsZero(): BOOLEAN

### LShift

    PROCEDURE (a: BigInt) LShift(n: LONGINT): BigInt

### Load

    PROCEDURE (a: BigInt) Load(r: Reader)
      RAISES Error;

> Loads data of a from r. Nested record pointers are loaded by calling the type-bound procecdure Reader.ReadObject. This procedure must be symmetric to Object.Store, or data internalization will break, causing undefined object state or program termination.

> Note: When internalizing a file with alien objects, it is possible that the type-bound procedure Object.Load is invoked more than once for a single object. Except for the results of the last call, all duplicates are discarded. Because of this, all changes by this procedure to any program state that is not part of the object a are deprecated.

> Pre-condition: This procedure is either activated by a super call, or from the procedure Reader.ReadObject.

> [Description inherited from Load]

> Redefines: Load, Load

### Mod

    PROCEDURE (v: BigInt) Mod(w: BigInt): BigInt

### Mul

    PROCEDURE (a: BigInt) Mul(b: BigInt): BigInt

### Neg

    PROCEDURE (a: BigInt) Neg(): BigInt

### NonZero

    PROCEDURE (a: BigInt) NonZero(): BOOLEAN

### RShift

    PROCEDURE (a: BigInt) RShift(n: LONGINT): BigInt

### Sign

    PROCEDURE (a: BigInt) Sign(): LONGINT

### Store

    PROCEDURE (a: BigInt) Store(w: Writer)
      RAISES Error;

> Stores data of a to w. Nested record pointers are stored by calling the type-bound procedure Writer.WriteObject. The procedure is not allowed to make any changes to the global state of the program, except for calling the ``Write`' methods of the writer w. Any redefinition of this procedure must include a super call, preferably as the first statement of the procedure body.

> Pre-condition: This procedure is either activated by a super call, or from the procedure Writer.WriteObject.

> [Description inherited from Store]

> Redefines: Store, Store

### Sub

    PROCEDURE (a: BigInt) Sub(b: BigInt): BigInt

### ToLongInt

    PROCEDURE (a: BigInt) ToLongInt(): LONGINT

### ToString

    PROCEDURE (a: BigInt) ToString(): String8

> Returns a string representation of the object. Typically, the string is some form of "natural" representation of the value. For complex objects, it should describe the type and essential attributes of the object. The exact format of the returned value is intentionally left vague.

> [Description inherited from ToString]

> Redefines: ToString, ToString, ToString

Type Detail

### Digit

    TYPE [Digit] = INTEGER

### DigitArray

    TYPE [DigitArray] = POINTER TO ARRAY OF Digit

Variable Detail

### one

    VAR one-: BigInt

### zero

    VAR zero-: BigInt