immutable class INT < $INTEGER{INT}, $OPTION, $EXACT_FMT
****

________This_immutable_class_is_one_of_the_most_fundamental_exact_number
___classes.__It_has_the_value_domain_from_an_implementation_specified_minimum
___to_some_maximum_value_also_determined_by_the_machine_representation
___provided.___All_arithmetic_on_values_of_this_class_is_signed.__This_class
___inherits_from_AVAL{BIT}._The_number_of_bits_in_the_representation_is
___identical_to_NUM_BITS::Num_Bits.

___NOTE_1.___The_Sather_language_requires_that_Num_Bits_be_at_least_32
________to_ensure_portability_of_exact_numeric_literals_up_to_this_size.

________2.___This_implementation_is_provided_for_machines_which_carry_out
________twos_complement_exact_arithmetic.__Pre-conditions_will_need_to_be
________modified_in_many_cases_where_other_representations_are_used.

________3.___Some_of_the_operations_raise_an_exception_on_overflow_or_through
________divide_by_zero!_They_are,_however,_only_guaranteed_to_do_this_if
________checking_is_enabled!__Enabling_checking,_however,_may_affect
________performance._Certain_machines_with_appropriate_hardware_may_perform
________these_checks_even_when_checking_is_not_enabled.


Ancestors
$EXACT_FMT $FMT $STR $OPTION
$INTEGER{_} $SIGNED{_} $CARDINAL{_} $VALUE_ITERS{_}
$LIMITED{_} $WHOLE_NUM{_} $SIMPLE_NUM{_} $HASH
$IS_EQ $SEQUENCERS{_} $COUNTS{_} $ARITHMETIC{_}
$ADD_OPS{_} $ZERO{_} $NFE{_} $TEXT
$BINARY $ORDERED{_} $IS_LT{_} $VALUE{_}
$NIL $IS_NIL $CONVERSION{_}



Public


Constants
const asize : CARD := 32 ;
**** const asize : CARD := NUM_BITS::Num_Bits ;
const is_exact : BOOL := true ;
const is_limited : BOOL := true ;
const is_signed : BOOL := true ;
const one : SAME := 1 ;
const two : SAME := 2 ;
const zero : SAME := 0 ;
**** See $NFE.

Features
abs : SAME
aget( .. Included as aget
aset( .. Included as aset
binstr : BINSTR
build(cursor : BIN_CURSOR) : SAME
build(loc_cursor : STR_CURSOR) : SAME .. Included as build
card : CARD
ceiling(other : SAME) : SAME
create(bits : BINSTR) : SAME
create(val : CARD) : SAME
create(val : FIELD) : SAME
create(val : FLT) : SAME
create(val : FLTD) : SAME
create(val : INT) : SAME
create(val : INTI) : SAME
create(val : QUADBITS ) : SAME
****
________This_private_routine_creates_a_new_code_using_the_implementation
___defined_built-in_facilities.__The_built-in_merely_returns_the_bit
___pattern_as_a_number_without_checking_for_overflow_-_not_needed_in
___this_bit_pattern_conversion_operation.
create(val : RAT) : SAME
create(str : STR) : SAME .. Included as create
cube : SAME
div(other:CARD): SAME
div(other : SAME) : SAME
evenly_divides(other : SAME) : BOOL
****
________This_predicate_returns_true_if_and_only_if_self_is_an_exact_divisor
___of_other.
exp10 : SAME
exp2 : SAME
extended_gcd(other:SAME, out f1, out f2:SAME):SAME
factorial : SAME
field : FIELD
flt : FLT
fltd : FLTD
fmt( .. Included as fmt
fmt( .. Included as fmt
gcd(other : SAME) : SAME
hash : CARD
****
in_range(lower, upper : SAME) : BOOL
****
________This_predicate_returns_true_if_and_only_if_self_has_a_value_between
___lower_and_upper_inclusive.__Built-in_to_this_implementation.
in_range(rng : $RANGE{INT}) : BOOL
****
________This_predicate_returns_true_if_and_only_if_self_has_a_value_within
___the_given_range.
in_tolerance(tolerance, val : SAME) : BOOL
****
________This_predicate_returns_true_if_and_only_if_self_is_within_the_given
___tolerance_of_val.
int : INT
inti : INTI
is_eq(other : SAME) : BOOL
****
________This_predicate_returns_true_if_and_only_if_self_and_other_represent
___the_same_value.
is_eq(other : $OB) : BOOL .. Included as is_eq
**** This is the generic equality predicate. c.f. the class $IS_EQ
is_even : BOOL
****
__This_predicate_returns_true_if_and_only_if_self_is_an_even_valued_number.
is_exp2 : BOOL
****
________This_predicate_returns_true_if_and_only_if_self_is_a_power_of_two.
is_int(str:STR):BOOL .. Included as is_int
**** This predicate returns true if and only if str represents a number in decimal notation.
is_lt(other : SAME) : BOOL
****
________This_predicate_returns_true_if_and_only_if_self_is_less_than_other.
___Built-in_to_this_implementation.
is_neg : BOOL
**** self<0
is_nil : BOOL
**** This predicate returns true if and only if self is nil.
is_non_neg:BOOL
**** self>=0
is_non_pos:BOOL
****
__self<=0
is_non_zero : BOOL
**** self/=0
is_odd : BOOL
****
__This_predicate_returns_true_if_and_only_if_self_is_an_odd_valued_number.
is_one: BOOL
is_pos : BOOL
****
__self>0
is_prime : BOOL
is_prime_to(other : SAME) : BOOL
****
________This_predicate_returns_true_if_and_only_if_self_is_relatively_prime_to_other.
is_whole(str : STR ) : CONVERSION_RESULTS .. Included as is_whole
is_zero : BOOL
**** self=0
lcm(other : SAME) : SAME
****
________This_routine_returns_the_least_common_multiple_of_self_and_other.
pre ((self.sign = other.sign) and ((self.sign = NUM_SIGNS::Negative)and ((minint / other) > self))or ((self.sign /= NUM_SIGNS::Negative)and ((maxint / other) < self)))or ((self.sign /= NUM_SIGNS::Negative)and ((minint / self) > other))or ((self.sign = NUM_SIGNS::Negative)and ((minint / other) > self))post (result * gcd(other)) = (self * other).abs
log(base : SAME) : SAME
log2 : SAME
max(other : SAME) : SAME
maxint : SAME
maxval : SAME
middle(first, second : SAME ) : SAME
min(other : SAME) : SAME
minint : SAME
minus(other:CARD): SAME
minus(other : SAME) : SAME
minval : SAME
mod(other:CARD): SAME
mod(other : SAME) : SAME
negatable : BOOL
****
________This_predicate_returns_true_if_and_only_if_the_implementation-
___dependent_value_domain_for_this_class_contains_a_representation_of
___the_negation_of_self,_otherwise_false.__Built-in_to_this_implementation.
negate : SAME
next_exp2 : SAME
nil : SAME
num_chars : CARD .. Included as num_chars
plus(other:CARD): SAME
plus(other : SAME) : SAME
pow(other:CARD): SAME
pow(power : SAME) : SAME
rat : RAT
read(index : BIN_CURSOR) : SAME .. Included as read
sgn:SAME
**** return 1/0/-1
sign : NUM_SIGNS
sqrt : SAME
square : SAME
str( .. Included as str
str : STR .. Included as str
times(other:CARD): SAME
times(other : SAME) : SAME
write(fyle : BIN_FILE) .. Included as write

Iters
aelt!( .. Included as aelt!
aelt!( .. Included as aelt!
aelt!( .. Included as aelt!
aelt! : BOOL
****
________This_iter_is_effectively_a_predicate_which_yields_true_or_false
___depending_upon_whether_the_successive_bits_of_self_are_set_or_not.
aind! : CARD .. Included as aind!
downto!(once limit : SAME) : SAME
for!(once cnt : SAME) : SAME
product!(other : SAME) : SAME
step!(once cnt : CARD, once step : SAME ) : SAME
stepto!( once to, once by : SAME ) : SAME
sum!(other : SAME) : SAME
times!
times! : SAME
up! : SAME
upto!( once limit : SAME) : SAME


Private

const Decimal_Base : CARD := 10 ; .. Included as Decimal_Base
const Max_Power := 19 ;
**** temporarily constant!!!
is_legal_aelts_arg( .. Included as is_legal_aelts_arg
opt_sign(cursor : STR_CURSOR) : BOOL .. Included as opt_sign
scan(cursor : STR_CURSOR) : SAME .. Included as scan
skip_space(cursor:STR_CURSOR) .. Included as skip_space

The Sather Home Page