Frama-C API - Integer
Extension of Big_int
compatible with Zarith
.
Euclidean division (that returns a positive rem). Implemented by Z.ediv
Equivalent to C division if both operands are positive. Equivalent to a floored division if b > 0 (rounds downwards), otherwise rounds upwards. Note: it is possible that e_div (-a) b <> e_div a (-b).
e_div_rem a b
returns (e_div a b, e_rem a b)
. Implemented by Z.ediv_rem
Remainder of the truncated division towards 0 (like in C99). Implemented by Z.rem
c_div_rem a b
returns (c_div a b, c_rem a b)
. Implemented by Z.div_rem
val is_zero : t -> bool
val is_one : t -> bool
val is_even : t -> bool
val zero : t
val one : t
val two : t
val four : t
val eight : t
val sixteen : t
val thirtytwo : t
val onethousand : t
val billion_one : t
val minus_one : t
val max_int64 : t
val min_int64 : t
val two_power_32 : t
val two_power_64 : t
val of_int : int -> t
val of_int64 : Stdlib.Int64.t -> t
val of_int32 : Stdlib.Int32.t -> t
val to_int_exn : t -> int
val to_int64_exn : t -> int64
val to_int32_exn : t -> int32
val to_int_opt : t -> int option
Returns Some i
if the number can be converted to an int
, or None
otherwise.
val to_int64_opt : t -> int64 option
Returns Some i
if the number can be converted to an int64
, or None
otherwise.
val to_int32_opt : t -> int32 option
Returns Some i
if the number can be converted to an int32
, or None
otherwise.
val to_float : t -> float
val of_float : float -> t
round_up_to_r m r modu
is the smallest number n
such that n
>=m
and n
= r
modulo modu
round_down_to_r m r modu
is the largest number n
such that n
<=m
and n
= r
modulo modu
val two_power_of_int : int -> t
Computes 2^n
val power_int_positive_int_opt : int -> int -> t option
Exponentiation
val popcount : t -> int
val hash : t -> int
val to_string : t -> string
val of_string : string -> t
Prints the integer in decimal format. See also pretty_hex
.
Prints the integer in hexadecimal format (replaces hexa
optional argument of pretty
from older versions).
Print binary format. Digits are output by blocs of 4 bits separated by ~sep
with at least ~nbits
total bits. If nbits
is non positive, it will be ignored.
Positive values are prefixed with "0b"
and negative values are printed as their 2-complement (lnot
) with prefix "1b"
.
Print hexadecimal format. Digits are output by blocs of 16 bits (4 hex digits) separated by ~sep
with at least ~nbits
total bits. If nbits
is non positive, it will be ignored.
Positive values are preffixed with "0x"
and negative values are printed as their 2-complement (lnot
) with prefix "1x"
.