# Boost :

From: helmut.zeisel_at_[hidden]
Date: 2001-08-21 12:39:41

here is some information what the interface now looks like:

--- In boost_at_y..., John Max Skaller <skaller_at_o...> wrote:

"b", "b1", "b2" denote big_int,
"i" a built-in like char, unsigned char, signed char,
unsigned short, signed short, unsigned int, signed int,
unsigned long, signed long.

>
> The basic interface is trivially obvious.
> You need the basic operations:
>
> comparisons
>
> and probably some mutators.

We have b1+b2, b+i, i+b, b1+=b2, b+=i,
b1-b2, b-i, i-b, b1-=b2, b-=i,
b1*b2, b*i, i*b, b1*=b2, b*=i,
b1/b2, b/i, i/b, b1/=b2, b/=i,
b1%b2, b%i, i%b, b1%=b2, b%=i,
big_int::div(b1,b2) (quotient_and_remainder)
b1<b2, b<i, i<b etc.

> The hard part is what _other_
> operations to provide. In particular, conversions to
> and from WHICH other types?

Construction from every built-in integral type as listed above.
Special conversion function to every built-in integral and float type:

convert<type>(b);

> Here's the big int interface from the Ocaml big_int module,
> note that at the time this was written, Ocaml only had one
> size of integer (int).
>
> type big_int
>
> val sign_big_int : big_int -> int

b.sign();

> val zero_big_int : big_int

b(0);

> val unit_big_int : big_int

b(1);

> val num_digits_big_int : big_int -> int

not provided

> val minus_big_int : big_int -> big_int

-b and b.change_sign()

> val abs_big_int : big_int -> big_int

b.abs()

> val compare_big_int : big_int -> big_int -> int

not provided

> val eq_big_int : big_int -> big_int -> bool

b1 == b2

> val le_big_int : big_int -> big_int -> bool

b1 <= b2

> val ge_big_int : big_int -> big_int -> bool

b1 >= b2

> val lt_big_int : big_int -> big_int -> bool

b1 < b2

> val gt_big_int : big_int -> big_int -> bool

b1 > b2

> val max_big_int : big_int -> big_int -> big_int

std::max

> val min_big_int : big_int -> big_int -> big_int

std::min

> val pred_big_int : big_int -> big_int

--b, b--

> val succ_big_int : big_int -> big_int

++b, b++

> val add_big_int : big_int -> big_int -> big_int

b1+b2

> val big_int_of_int : int -> big_int

b(i)

> val add_int_big_int : int -> big_int -> big_int

b+i, i+b

> val sub_big_int : big_int -> big_int -> big_int

b1+b2

> val mult_int_big_int : int -> big_int -> big_int

b*i, i*b

> val mult_big_int : big_int -> big_int -> big_int

b1*b2

> val quomod_big_int : big_int -> big_int -> big_int * big_int

big_int::div(b1,b2)

> val div_big_int : big_int -> big_int -> big_int

b1/b2

> val mod_big_int : big_int -> big_int -> big_int

b1%b2

> val gcd_big_int : big_int -> big_int -> big_int

Template from rational.hpp

> val int_of_big_int : big_int -> int

convert<int>(b)

> val is_int_big_int : big_int -> bool

convertable<int>(b)

> val nat_of_big_int : big_int -> nat
> val big_int_of_nat : nat -> big_int

Not provided

> val string_of_big_int : big_int -> string

b.to_string()

> val big_int_of_string : string -> big_int

b(const std::string&), b(const char*)

> val float_of_big_int : big_int -> float

convert<float>(b)

> val square_big_int: big_int -> big_int

pow(b,2)

> val sqrt_big_int: big_int -> big_int

Not provided

> val base_power_big_int: int -> int -> big_int -> big_int

Not provided; we have, however b<<n, b>>n b<<=n, b >>=n

> val sys_big_int_of_string: string -> int -> int -> big_int

what should that be?

> val power_int_positive_int: int -> int -> big_int
> val power_big_int_positive_int: big_int -> int -> big_int
> val power_int_positive_big_int: int -> big_int -> big_int
> val power_big_int_positive_big_int: big_int -> big_int -> big_int

pow(b,i), pow(b1,b2)

> val round_futur_last_digit : string -> int -> int -> bool
> val approx_big_int: int -> big_int -> string

Not provided
>
>
> and here's the one for unsigned numbers:
>

I do not have unsigned numbers, it is not clear to me,
what, e.g., the result type of n-b should be.
To be consistent with built-in int, it should be unsigned,
which IMHO makes not really sense.

Helmut