Prime_int
Integer functions.
val sign : int -> int
sign n is compare n 0.
sign n
compare n 0
val delta : int -> int -> int
delta n m is 1 if n = m, 0 otherwise.
delta n m
1
n = m
0
val pow : int -> int -> int
pow b n is b raised to n.
pow b n
b
n
if n < 0.
n < 0
val fdiv : int -> int -> int
fdiv n m is the quotient of floored division, ⌊n / m⌋.
fdiv n m
⌊n / m⌋
val fmod : int -> int -> int
fmod n m is the remainder of floored division, n / m - ⌊n / m⌋.
fmod n m
n / m - ⌊n / m⌋
val cdiv : int -> int -> int
cdiv n m is the quotient of ceiled division, ⌈n / m⌉.
cdiv n m
⌈n / m⌉
val cmod : int -> int -> int
cmod n m is the remainder of ceiled division, n / m - ⌈n / m⌉.
cmod n m
n / m - ⌈n / m⌉
val gcd : int -> int -> int
gcd n m is the greatest common divisor of n and m.
gcd n m
m
val fact : int -> int
fact n is the factorial of n representing the number of ways to order n distinct elements.
fact n
val binom : int -> int -> int
binom n k is the binominal coefficient corresponding to the number of ways to choosing k elements out of n.
binom n k
k
if the result cannot be represented as an int.
int
val signed_width : int
The number of non-sign bits of an int.
val bitcount : int -> int
bitcount n is the number of ones in the binary representation of n.
bitcount n
val floor_log2 : int -> int
floor_log2 n is ⌊log₂ n⌋.
floor_log2 n
⌊log₂ n⌋
val ceil_log2 : int -> int
ceil_log2 n is ⌈log₂ n⌉.
ceil_log2 n
⌈log₂ n⌉
val fold_to : (int -> 'a -> 'a) -> int -> 'a -> 'a
fold_to f n returns f (n - 1) ∘ ⋯ ∘ f 0.
fold_to f n
f (n - 1) ∘ ⋯ ∘ f 0