class INTI < $WHOLE_NUM{INTI}, $SIGNED{INTI}, $VALUE_ITERS{INTI}, $EXACT_FMT
****

________This_class_implements_arbitrarily_large_integers.___An_integer_is
___represented_by_n_digits_to_a_base_B,_ie,_where_array_element_zero_is
___written_first_-

________x_=_sign_*_(x[0]_+_x[1]*B_+_..._+_x[n-2]*B^(n-2)_+_x[n-1]*B^(n-1))

________The_n_digits_x[i]_of_x_are_held_in_an_array_with_asize_>=_n._The
___sign_and_n_are_encoded_in_a_private_feature_len,_with_the_following
___semantics_--

________n_=_|len|,_sign_=_sign(len)

___the_value_0_is_represented_by_len_=_0

________The_operations_div_(/)_and_mod_(%)_obey_the_following_rules

________x_=_(x/y)*y_+_x%y___and___0_<=_x%y_<_|y|

___NOTE_1.___Objects_of_this_class_behave_like_an_immutable_class_object.

________2.___WARNING_The_possibility_of_an_infinite_integer_reaching
________the_memory_limit_boundary_is_not_considered_in_setting_any_pre
________and_post_condition!!


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



Public


Constants
const is_exact : BOOL := true ;
const is_limited : BOOL := false ;
const is_signed : BOOL := true ;

Features
abs : SAME
aclear .. Included as aclear
acopy(beg, num, srcbeg : CARD, src : SAME) .. Included as acopy
acopy(beg, num : CARD, src : SAME) .. Included as acopy
acopy(beg : CARD, src : SAME) .. Included as acopy
acopy(src : SAME) .. Included as acopy
aget(index : CARD) : ELT .. Included as aget
aget(index : INT) : ELT .. Included as aget
array_ptr : REFERENCE .. Included as array_ptr
aset(index : CARD, val : ELT) .. Included as aset
aset(index : INT, val:ELT) .. Included as aset
asize : CARD .. Included as asize
binstr : BINSTR
build(cursor : BIN_CURSOR) : SAME
build(loc_cursor : STR_CURSOR) : SAME .. Included as build
card : CARD
ceiling(val : SAME) : SAME
cmp(other : SAME) : INT
create(str : BINSTR) : SAME .. Included as create
create(val : CARD) : SAME
****
__This_routine_creates_an_INTI_from_the_given_cardinal_value.
create(val : FIELD) : SAME
****
__This_routine_creates_an_INTI_from_the_given_field_value.
create(val : FLT) : SAME
****
__Provided_that_val_is_an_integer_value,_this_routine_creates
__an_equivalent_valued_INTI_object.
create(val : FLTD) : SAME
****
__Provided_that_val_is_an_integer_value,_this_routine_creates
__an_equivalent_valued_INTI_object.
create(str : FSTR) : SAME .. Included as create
create(str : FSTR,index : CARD) : SAME .. Included as create
create(val : INT) : SAME
****
__This_routine_creates_an_INTI_from_the_given_integer_value.
create(val : INTI) : SAME
****
__This_routine_returns_the_argument_--_a_vacuous_routine.
create(val : RAT) : SAME
****
__This_routine_creates_an_INTI_from_the_given_rational_value,
__using_the_value_rounded_to_the_nearest_whole_number.
create(str : STR) : SAME .. Included as create
create(str : STR,index : CARD) : SAME .. Included as create
cube : SAME
decimal_str : STR .. Included as decimal_str
digits : FLIST{CARD} .. Included as digits
div(other:CARD): SAME
div(other:INT): SAME
div(other : SAME) : SAME
evenly_divides(val : SAME) : BOOL
****
__This_predicate_returns_true_if_and_only_if_there_is_no_remainder_when
__dividing_self_by_val.
exp10 : SAME
exp2 : SAME
extended_gcd(other:SAME, out f1, out f2:SAME):SAME
factorial : SAME
field : FIELD
flt : FLT
fltd : FLTD
fmt(format : EXACT_DESCR) : STR .. Included as fmt
fmt(format : EXACT_DESCR,lib : LIBCHARS) : STR .. Included as fmt
gcd(other : SAME) : SAME
hash : CARD
in_range(lower, upper : SAME) : BOOL
****
__true_if_and_only_if_lower<=_self_<=_upper.
in_range(rng : $RANGE{INTI} ) : 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_have_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_number.
is_exp2 : BOOL
is_fpsp(base : INTI) : BOOL
****
__This_routine_returns_true_if_and_only_if_self_is_either_prime_or
__Fermat's_pseudo-prime_of_the_given_base.
is_inti(str : STR) : CONVERSION_RESULTS .. Included as is_inti
is_lt(other : SAME) : BOOL
****
__This_predicate_returns_true_if_and_only_if_self_is_less_than_other.
is_neg : BOOL
****
__This_predicate_returns_true_if_and_only_if_self_is_less_than_zero.
is_nil : BOOL
****
__This_predicate_returns_true_if_and_only_if_self_has_the_value_nil.
is_non_neg : BOOL
is_non_pos : BOOL
is_non_zero : BOOL
is_odd : BOOL
****
__This_predicate_returns_true_if_and_only_if_self_is_an_odd_number.
is_one:BOOL
is_pos : BOOL
****
__This_predicate_returns_true_if_and_only_if_self_is_greater_than_zero.
is_prime : BOOL
****
__This_predicate_returns_true_if_and_only_if_self_is_a_prime_number.
__This_is_not_a_fast_implementation!
is_prime_to(other : SAME) : BOOL
****
__This_predicate_returns_true_if_and_only_if_self_is_relatively_prime_to_other.
is_zero : BOOL
****
__This_predicate_returns_true_if_and_only_if_self_is_zero.
lcm(other : SAME) : SAME
log2 : INTI
max(other : SAME) : SAME
middle(first, second : SAME) : SAME
min(other : SAME) : SAME
minus(other:CARD): SAME
minus(other:INT): SAME
minus( other : SAME ) : SAME
mod(other:CARD): SAME
mod(other:INT): SAME
mod(other : SAME) : SAME
negatable : BOOL
****
__This_predicate_returns_true_if_and_only_if_this_class_is_numeric_and
__negatable_--_trivially_true!
negate : SAME
nil : SAME
****
__This_routine_returns_a_nil_value_which_may_not_be_used_in_arithmetic.
one : SAME
****
__This_is_a_'constant'_of_the_value_1!
plus(other:CARD): SAME
plus(other:INT): SAME
plus( other : SAME ) : SAME
pow(other:CARD): SAME
pow(other:INT): SAME
pow(exp : SAME ) : SAME
rat : RAT
read(index : BIN_CURSOR) : SAME .. Included as read
sgn:SAME
**** return int value of 1/0/-1
sign : NUM_SIGNS
sqrt : SAME
square : SAME
str(lib : LIBCHARS) : STR .. Included as str
str : STR .. Included as str
times(other:CARD): SAME
times(other:INT): SAME
times( other : SAME ) : SAME
two : SAME
****
__This_routine_returns_the_value_two.
write(fyle : BIN_FILE) .. Included as write
zero : SAME
****
__This_is_a_'constant'_of_the_value_0!

Iters
aelt!(once beg : CARD) : ELT .. Included as aelt!
aelt!(once beg, once num : CARD) : ELT .. Included as aelt!
aelt!(once beg,once num : CARD,once step : INT) : ELT .. Included as aelt!
aelt! : ELT .. Included as aelt!
aind! : CARD .. Included as aind!
aset!(val : ELT) .. Included as aset!
aset!(once beg : CARD,val : ELT) .. Included as aset!
aset!(once beg, once num : CARD, val : ELT) .. Included as aset!
aset!(once beg, once num : CARD, once step : INT,val : ELT) .. Included as aset!
downto!(once limit : SAME) : SAME
****
for!( once cnt : SAME ) : SAME
product!(other : SAME) : SAME
step!(once cnt : CARD, once step : INT ) : SAME
stepto!(once to : SAME, once by : INT) : SAME
sum!(other : SAME) : SAME
times!
times! : SAME
up! : SAME
upto!( once limit : SAME) : SAME
****


Private

const Bin2 : CARD := Bin*Bin;
const Bin : CARD := 2 ^ log2B ;
**** binary base
const Decimal : CARD := 10 ^ log10D ; .. Included as Decimal
**** decimal base; D <= B
const Default : CARD := 289201 ;
**** for an 'empty' number
const Default_Base : CARD := 10 ; .. Included as Default_Base
**** for conversions!
const Max_Card : SAME := create(CARD::maxval) ;
const Max_Double : SAME := create(FLTD::maxval.truncate) ;
const Max_Float : SAME := create(FLT::maxval.truncate) ;
const Max_Int : SAME := create(INT::maxval) ;
const Min_Int : SAME := create(INT::minval) ;
const Prime : FIELD := 19 ;
**** Hashing constant
copy : SAME
for_all(first, second : SAME) : BOOL .. Included as for_all
****
__This_private_predicate_returns_true_if_and_only_if_all_elements_of
___first_and_second_are_the_same!
get_u_div(first, second, quotient : SAME ) : SAME
get_u_mod( first, second, quotient : SAME ) : SAME
is_legal_aelts_arg(beg, num : CARD, step : INT) : BOOL .. Included as is_legal_aelts_arg
**** This predicate returns true if and only if the arguments are legal
___values_for_aelt_and_aset_iters_below.
attr len : INT ;
attr len : INT ;
const log10D : CARD := 4 ; .. Included as log10D
****
const log2B : CARD := 15 ;
****
opt_sign(cursor : STR_CURSOR) : BOOL .. Included as opt_sign
scan(cursor : STR_CURSOR,out negative : BOOL) : FLIST{CARD} .. Included as scan
to_digits(base : CARD) : FLIST{CARD} .. Included as to_digits
u_cmp( first, second : SAME ) : INT
u_div_mod(first, second : SAME ) : SAME
u_minus( first, second : SAME ) : SAME
u_mod( val : SAME, divisor : CARD ) : CARD
u_plus( left, right : SAME ) : SAME
u_times( first, second : SAME ) : SAME
u_times_plus( val : SAME, factor, coeff : CARD ) : SAME

The Sather Home Page