<> <> <> <> <> DIRECTORY Rope USING [ROPE]; BigCardinals: CEDAR DEFINITIONS = BEGIN <<***** Data Structure ***** Big cardinals are represented in a radix of 2^16. The digits are stored as a sequence of cardinals, with the low order digit at contents[0]. Zero is represented with size = 0.>> BigCARD: TYPE = RECORD [size: CARDINAL _ 0, contents: REF BigCARDRec _ NIL]; BigCARDRec: TYPE = RECORD [SEQUENCE max: CARDINAL OF CARDINAL]; <> Zero: BigCARD = [0, NIL]; <> <<>> BigFail: ERROR [subclass: ATOM _ $Unspecified]; <> <<***** Basic Arithmetic *****>> BigAdd: PROC [in1, in2: BigCARD] RETURNS [BigCARD]; BigSubtract: PROC [large, small: BigCARD, reuse: BOOL _ FALSE] RETURNS [BigCARD]; <> <> BigMultiply: PROC [in1, in2: BigCARD] RETURNS [BigCARD]; BigDivMod: PROC [num, den: BigCARD, reuse: BOOL _ FALSE] RETURNS [quo, rem: BigCARD]; <> <> <<***** Conversion Routines ***** There are two kinds of conversion routines between Ropes and BigCardinals. If the word Decimal appears in the name then the Ropes involved are human readable strings of the digits 0..9, that is, the standard base 10 representation of a BigCardinal.>> BigFromDecimalRope: PROC [in: Rope.ROPE] RETURNS [BigCARD]; BigToDecimalRope: PROC [in: BigCARD, reuse: BOOL _ FALSE] RETURNS [Rope.ROPE]; <> BigFromRope: PROC[in: Rope.ROPE] RETURNS [out: BigCARD]; BigToRope: PROC [in: BigCARD] RETURNS [out: Rope.ROPE]; BigFromSmall: PROC [in: CARDINAL] RETURNS [BigCARD]; BigToSmall: PROC [in: BigCARD] RETURNS [CARDINAL]; <> <<***** Copy and Comparison *****>> BigCopy: PROC [in: BigCARD] RETURNS [BigCARD]; <> <> BigCompare: PROC [in1, in2: BigCARD] RETURNS [BigRelation]; BigRelation: TYPE = {bigLess, bigEqual, bigGreater}; <> BigZero: PROC [in: BigCARD] RETURNS [BOOL]; BigOdd: PROC [in: BigCARD] RETURNS [BOOL]; <<***** Exotic Functions *****>> BigRandom: PROC [length: CARDINAL _ 0, max, min: BigCARD _ Zero] RETURNS [BigCARD]; <> <<1) If `length' is nonzero than the result has `length' digits of radix 2^16>> <<2) If `length' is zero than the result is in the range [min, max]>> BigExponentiate: PROC [base, exponent, modulus: BigCARD, reuse: BOOL _ FALSE] RETURNS [BigCARD]; <> <> BigGCD: PROC [in1, in2: BigCARD] RETURNS [out: BigCARD]; BigInverse: PROC [in, modulus: BigCARD] RETURNS [out: BigCARD]; <> <> BigPrimeTest: PROC [prime: BigCARD, accuracy: CARDINAL _ 20] RETURNS [BOOL]; <> END.