**** The most fundamental integer class. Signed, unsigned, and modular versions of arithmetic operations are provided. The names of unsigned operations begin with the letter "u". The names of modular operations begin with the letter "m". Negative numbers are represented using 2's complement. INT objects inherit from AVAL{BOOL}. The number of bits in the representation is `asize' and is implementation dependent. It must be at least 32, however (to ensure portability of INT literals up to this size). Many of the operations are specified to raise exceptions on overflow. They are guaranteed to do this if checking is enabled, but this may affect performance. Certain machines (with appropriate hardware) may perform these checks even when checking is not enabled. The modular operations are performed modulo 2^asize. _ References: Keith O. Geddes, Stephen R. Czapor, and George Labahn, "Algorithms for Computer Algebra", Kluwer Academic Publishers, Boston, 1992.

Flattened version is here

Ancestors
 \$FMT \$HASH \$IS_EQ \$NUMBER{_} \$NFE{_} \$STR \$NIL \$IS_NIL \$IS_LT{_}

Public

Constants
 **** Size in bits.
 ****
 **** See \$NUMBER.

Features
 **** The absolute value of self. Built-in.
aget(i:INT):BOOL
aset(i:INT,j:BOOL):INT
 **** Same as `max(x)'.
 **** Same as `min(x)'.
 **** The bitwise and of self and `i'.
 **** The number of bits in self which are set to 1.
 **** The bits of res are 1 in positions where self and `i' have the same bit values.
 **** The binary representation of self of the form "0b100100". Self is interpreted as an unsigned integer.
 **** True if bit `i' of self is 1.
 **** The bitwise nand of self and `i'.
 **** The bitwise nor of self and `i'.
 **** The bitwise complement of self.
 **** A boolean from self. Built-in.
 **** The bits of res are combinations of the corresponding bits of self and `i' combined according to a rule specified by `rule'. This must be a value between 0 and 15. The low order bit says what to map a 0 in self and a 0 in `i' to, the second bit of `rule' says what to map 0,1 to, the third bit defines 1,0 and the fourth 1,1.
 **** The bitwise inclusive or of self and `i'.
 **** The bitwise exclusive or of self and `i'.
 **** Convert to external C unsigned integer. Built-in.
 **** A character corresponding to the value of self. Built-in.
create(f:FLT):SAME
create(f:FLTD):SAME
create(x:INT):SAME
create(x:INTI):SAME
create(s:STR): SAME
 **** The cube of self.
 **** A character representing self. If self is between 0 and 9, it returns a digit. If between 10 and 15, returns 'A' thru 'F'.
 **** The signed quotient of self and `i'. This and `mod' have the property that for non-zero `y', `x=x.div(y)*x + x.mod(y)'. Raises an exception when `i' is 0, when enabled. Built-in.
 **** True if self evenly divides `i'.
 **** Ten to the self power. Small values use lookup table for speed.
exp2:SAME
 **** The three parts of the return value `g', `g1', and `g2' are such that `g' is the greatest common divisor of self and `i' and `g1*self+g2*i=g'. Uses the extended Euclidean algorithm. Geddes, et. al. p. 36.
 **** The factorial of self. Replace by faster algorithm.
 **** A floating point version of self. It is an error if the value cannot be held in a FLT. Built-in.
 **** A double floating point version of self. It is an error if the value cannot be held in a FLTD. Built-in.
fmt( f: STR ): STR
 **** Returns `i'.
 **** The greatest common divisor of self and `i'. The result is non-negative and `x.gcd(0)=x.abs'. Uses Euclidean algorithm. Geddes, et. al. p. 34.
hash:INT
 **** The hexadecimal representation of self of the form "0x5A". Self is interpreted as an unsigned integer.
 **** The high `i' bits of self with 0 in the lower positions.
 **** The position of the highest non-zero bit of self. -1 if none.
 **** An integer version of self.
 **** An infinite precision version of self.
 **** True if self between l and u. Built-in.
 **** True if self between l and u. Built-in.
 **** True if self and `i' represent the same value. return self=i
 **** True if self equals `i1' and `i2'.
 **** True if self equals `i1', `i2', and `i3'.
is_even:BOOL
 **** returns true iff self is positive and a power of two
 **** True if self is less than `i' as signed integers. Built-in.
 **** True if self is less than zero.
is_nil:BOOL
 **** True if self is non-negative.
 **** True if self is non-positive.
 **** True if self is non-zero.
is_odd:BOOL
 **** True if self is greater than zero.
is_pow_of_2:BOOL is return is_exp2 end;
 **** True if self is a prime number. Replace by a faster algorithm.
 **** True if self is relatively prime to `i'.
 **** True if self is greater than or equal to `i' as unsigned integers.
 **** True if self is greater than `i' as unsigned integers.
 **** True if self is less than or equal to `i' as unsigned integers.
is_ult(lhs:SAME):BOOL
is_within(tolerance,val:SAME):BOOL
 **** True if self is zero.
 **** The least common multiple of self and `i'. Geddes, et. al. p. 28.
log2:INT
 **** The low `i' bits of self with 0 in the higher positions.
 **** The position of the lowest non-zero bit of self. -1 if none.
 **** Left rotate the bits of self by `i' places.
 **** The bits of self shifted left by `i' places with zeroes shifted in on the right.
 **** The larger of self and `i' as signed integers. Built-in.
maxint:INT
 **** See \$NUMBER.
 **** The unsigned quotient of self and `i'. Raises an exception when `i' is 0, when enabled. Built-in.
 **** The smaller of self and `i' as signed integers. Built-in.
minint:INT
 **** The signed difference between self and `i'. Raises an exception on overflow, when enabled. Built-in.
 **** See \$NUMBER.
 **** The difference between self and `i' modulo 2^asize. Never raises an exception. Built-in.
 **** Unsigned remainder of self divided by `i'. Raises an exception when `i' is 0, when enabled.
 **** The additive inverse of self modulo 2^asize. Never raises an exception.
 **** Signed remainder of self divided by `i'. This and `mod' have the property that for non-zero `y', `x=x.div(y)*x + x.mod(y)'. It's also true that `0 <= x.mod(y) < y.abs'. Raises an exception when `i' is 0, when enabled. Built-in.
 **** The sum of self and `i' modulo 2^asize. Never raises an exception. Built-in.
 **** The product of self and `i' modulo 2^asize. Never raises an exception. Built-in.
 **** The signed negation of self. Same as zero minus self. Only raises an exception on the most negative value (which doesn't have a corresponding positive value in 2's complement.) Built-in.
 **** for self positive it returns the p so that the following holds: p.is_pow_of_2 and p>=self>(p/2)
 **** The smallest value greater than or equal to self which is a multiple of `i'.
next_pow_of_2:INT
 **** The value to be used to represent no element in sets. The most negative value.
 **** The number of decimal digits in non-negative self. Use binary search so that small values take only 3 compares.
 **** The octal representation of self of the form "0o15". Self is interpreted as an unsigned integer.
 **** The signed sum of self and `i'. Raises an exception on overflow, when enabled. Built-in.
 **** Self raised to the power `i'.
 **** Right rotate the bits of self by `i' places.
 **** The bits of self shifted right by `i' places with bits equal to the first bit of self shifted in on the left.
 **** Self with bit `i' set to 1.
 **** Self with bit `i' set to b.
 **** -1,0,1 depending on the sign of self. Steele, 304
 **** The largest integer whose square is smaller than self.
 **** The square of self. Built-in.
str:STR
 **** Append a decimal string version of self to `s' and return it.
 **** Append a string representation of self to s using at least n digits to the base b and return s. If less then n digits are used for the representation of self (including its sign), the remaining left_most positions are filled with character f.
ten_pow:SAME
 **** The signed product of self and `i'. Raises an exception if the product can't be held in the result, when enabled. Built-in.
 **** The unsigned quotient of self and `i'. Raises an exception when `i' is 0, when enabled. Built-in.
 **** The larger of self and `i' as unsigned integers.
 **** The smaller of self and `i' as unsigned integers.
 **** The unsigned difference between self and `i'. Raises an exception on overflow or if the result would be negative, when enabled. Built-in.
 **** Unsigned remainder of self divided by `i'. Raises an exception when `i' is 0, when enabled. Built-in.
 **** Self with bit `i' set to 0.
 **** The unsigned sum of self and `i'. Raises an exception on overflow, when enabled. Built-in.
 **** The bits of self shifted right by `i' places with zeroes shifted in on the left.
 **** The unsigned product of self and `i'. Raises an exception if the product can't be held in the result, when enabled. Built-in.
 **** Same as `max(x).min(y)'.

Iters
aelt!:BOOL
 **** Yield successive integers from self down to `i' inclusive.
 **** Yields `i' successive integers starting with self.
 **** Yields the product of all previous values of `i'.
 **** Yield `num' integers starting with self and stepping by `step'.
 **** Yield succeeding integers from self to `to' by step `by'. Might quit immediately if self is aleady `beyond'.
 **** Yields the sum of all previous values of `i'.
 **** Yields self times without returning anything.
 **** Yield successive integers from 0 up to self-1.
 **** Yield successive integers from self up.
 **** Yield successive integers from self to `i' inclusive.