Module Extraction_plugin.Big
Arithmetic operations
val add_int : int -> Big_int.big_int -> Big_int.big_intAddition of a small integer to a big integer.
val mult_int : int -> Big_int.big_int -> Big_int.big_intMultiplication of a big integer by a small integer
val sqrt : Big_int.big_int -> Big_int.big_intsqrt_big_int areturns the integer square root ofa, that is, the largest big integerrsuch thatr * r <= a. RaiseInvalid_argumentifais negative.
val quomod : Big_int.big_int -> Big_int.big_int -> Big_int.big_int * Big_int.big_intEuclidean division of two big integers. The first part of the result is the quotient, the second part is the remainder. Writing
(q,r) = quomod_big_int a b, we havea = q * b + rand0 <= r < |b|. RaiseDivision_by_zeroif the divisor is zero.
val div : Big_int.big_int -> Big_int.big_int -> Big_int.big_intEuclidean quotient of two big integers. This is the first result
qofquomod_big_int(see above).
val modulo : Big_int.big_int -> Big_int.big_int -> Big_int.big_intEuclidean modulus of two big integers. This is the second result
rofquomod_big_int(see above).
val gcd : Big_int.big_int -> Big_int.big_int -> Big_int.big_intGreatest common divisor of two big integers.
val power : Big_int.big_int -> Big_int.big_int -> Big_int.big_intExponentiation functions. Return the big integer representing the first argument
araised to the powerb(the second argument). Depending on the function,aandbcan be either small integers or big integers. RaiseInvalid_argumentifbis negative.
Comparisons and tests
val sign : Big_int.big_int -> intReturn
0if the given big integer is zero,1if it is positive, and-1if it is negative.
val compare : Big_int.big_int -> Big_int.big_int -> intcompare_big_int a breturns0ifaandbare equal,1ifais greater thanb, and-1ifais smaller thanb.
val eq : Big_int.big_int -> Big_int.big_int -> boolval le : Big_int.big_int -> Big_int.big_int -> boolval ge : Big_int.big_int -> Big_int.big_int -> boolval lt : Big_int.big_int -> Big_int.big_int -> boolval gt : Big_int.big_int -> Big_int.big_int -> boolUsual boolean comparisons between two big integers.
Conversions to and from strings
Conversions to and from other numerical types
val is_int : Big_int.big_int -> boolTest whether the given big integer is small enough to be representable as a small integer (type
int) without loss of precision. On a 32-bit platform,is_int_big_int areturnstrueif and only ifais between 230 and 230-1. On a 64-bit platform,is_int_big_int areturnstrueif and only ifais between -262 and 262-1.
val to_int : Big_int.big_int -> intConvert a big integer to a small integer (type
int). RaisesFailure "int_of_big_int"if the big integer is not representable as a small integer.
val double : Big_int.big_int -> Big_int.big_intval doubleplusone : Big_int.big_int -> Big_int.big_intval nat_case : (unit -> 'a) -> (Big_int.big_int -> 'a) -> Big_int.big_int -> 'aval positive_case : (Big_int.big_int -> 'a) -> (Big_int.big_int -> 'a) -> (unit -> 'a) -> Big_int.big_int -> 'aval n_case : (unit -> 'a) -> (Big_int.big_int -> 'a) -> Big_int.big_int -> 'aval z_case : (unit -> 'a) -> (Big_int.big_int -> 'a) -> (Big_int.big_int -> 'a) -> Big_int.big_int -> 'aval compare_case : 'a -> 'a -> 'a -> Big_int.big_int -> Big_int.big_int -> 'aval nat_rec : 'a -> ('a -> 'a) -> Big_int.big_int -> 'aval positive_rec : ('a -> 'a) -> ('a -> 'a) -> 'a -> Big_int.big_int -> 'aval z_rec : 'a -> (Big_int.big_int -> 'a) -> (Big_int.big_int -> 'a) -> Big_int.big_int -> 'a