CCInt
include module type of CCShimsInt_
include module type of struct include Stdlib.Int end
val zero : t
zero
is the integer 0
.
val one : t
one
is the integer 1
.
val minus_one : t
minus_one
is the integer -1
.
val max_int : t
max_int
is the maximum integer.
val min_int : t
min_int
is the minimum integer.
compare x y
is the comparison function for integers with the same specification as Stdlib
.compare.
val hash : t -> int
hash x
computes the hash of x
.
val sign : t -> int
sign x
return 0
if x = 0
, -1
if x < 0
and 1
if x > 0
. Same as compare x 0
.
pow base exponent
returns base
raised to the power of exponent
. pow x y = x^y
for positive integers x
and y
. Raises Invalid_argument
if x = y = 0
or y
< 0.
floor_div x n
is integer division rounding towards negative infinity. It satisfies x = m * floor_div x n + rem x n
.
val random : int -> t random_gen
val random_small : t random_gen
val random_range : int -> int -> t random_gen
val to_float : t -> float
to_float
is the same as float_of_int
val to_string : t -> string
to_string x
returns the string representation of the integer x
, in signed decimal.
val of_string : string -> t option
of_string s
converts the given string s
into an integer. Safe version of of_string_exn
.
val of_string_exn : string -> t
of_string_exn s
converts the given string s
to an integer. Alias to int_of_string
.
val of_float : float -> t
of_float x
converts the given floating-point number x
to an integer. Alias to int_of_float
.
val to_string_binary : t -> string
to_string_binary x
returns the string representation of the integer x
, in binary.
range_by ~step i j
iterates on integers from i
to j
included, where the difference between successive elements is step
. Use a negative step
for a decreasing list.
range i j
iterates on integers from i
to j
included . It works both for decreasing and increasing ranges.
range' i j
is like range
but the second bound j
is excluded. For instance range' 0 5 = Iter.of_list [0;1;2;3;4]
.
val popcount : t -> int
Number of bits set to 1
module Infix : sig ... end
include module type of Infix