"Int" provides a number of literal forms for its objects. "Int"s can be denoted in any base from 2 to 36 inclusive using the literal form:

<integer_literal> -> [ <base> "_" ] <integer_digits>The base and the underscore can be omitted to use the default base 10. The base is always interpreted as a decimal number and must be between 2 and 36 inclusive. The digits of the integer are indicated using the numbers 0 to 9 and, if necessary, the appropriate letters of the alphabet. For example, for base 16, the digits are "0...9", "a...f". The upper and lower case characters of the alphabet are considered equivalent in integer literals. No spaces are allowed within an integer literal. Here are some examples of literals with their corresponding base 10 form:

Literal Base 10 form 25 25 10_25 25 16_1c 28 16_1C 28 8_72 58 3_2001 55 2_1101 13

The following equates in the Theta environment denote the range of representable integers.

int_max an integer value indicating the smallest representable integer int_min an integer value indicating the largest representable integerInteger values are representable in 32 bits and therefore under a twos-complement machine representation for integers, "int_max" will be [tex2html_wrap2958] and "int_min" will be [tex2html_wrap2959].

Methods for type "int"

negate ( ) returns (int) signals (overflow) % effects returns -self; signals overflow if the result is not % in the representable range. add (x: int) returns (int) signals (overflow) % effects returns self + x; signals overflow if the sum is not % in the representable range. subtract (x: int) returns (int) signals (overflow) % effects returns self - x; signals overflow if the result is not % in the representable range. multiply (x: int) returns (int) signals (overflow) % effects returns self * x; signals overflow if the result is not % in the representable range. divide (x: int) returns (int) signals (zero_divide, overflow) % effects if x = 0 signals zero_divide. Otherwise returns self/x. % The result is rounded toward negative infinity. Signals % overflow if the result is not in the representable range. mod (x: int) returns (int) signals (zero_divide) % effects if x = 0 signals zero_divide. Otherwise returns self mod x. % This is the remainder when self is divided by x, and % is defined such that self = (self/x) * x + self.mod(x) power (x: int) returns (int) signals (negative_exponent, overflow) % effects if x < 0, signals negative_exponent. Otherwise returns self to the x power; % If self = 0, then self.power(0) is defined to be 1. % Signals overflow if the result is not in the representable range. abs ( ) returns (int) signals (overflow) % effects returns |self|; signals overflow if the result is not in the representable range. to (bound: int) yields (int) % effects yields the ints from self to bound in order; if bound < self yields nothing to_by (bound: int, step: int) yields (int) % effects yields the ints self, self + step, ... up to bound inclusive. max (x: int) returns (int) % effects returns the larger of self and x min (x: int) returns (int) % effects returns the smaller of self and x lt (x: int) returns (bool) % effects returns (self < x) le (x: int) returns (bool) % effects returns (self \tex{$\le$} x) gt (x: int) returns (bool) % effects returns (self > x) ge (x: int) returns (bool) % effects returns (self \tex{$\ge$} x) equal (x: int) returns (bool) % effects returns (self = x) similar (x: int) returns (bool) % effects returns (self = x) copy ( ) returns (int) % effects returns self unparse ( ) returns (string) % effects returns a string representing self in base 10. E.g., if self is 123, returns % the three character string ``123'' to_real ( ) returns (real) % effects converts self to a real and returns the result; % rounds toward zero; % assumes the range of real values covers range of integer values to_char ( ) returns (char) signals (illegal_char) % effects If self represents the ASCII code for a character, then % returns that character, else signals illegal_char.

theta-questions@lcs.mit.edu