Module CCInt
Basic Int functions
include module type of CCShimsInt_
Documentation for the standard Int module
include Stdlib.Int
val neg : int -> int
val add : int -> int -> int
val sub : int -> int -> int
val mul : int -> int -> int
val div : int -> int -> int
val rem : int -> int -> int
val succ : int -> int
val pred : int -> int
val zero : t
zero
is the integer0
.- since
- 3.0
val one : t
one
is the integer1
.- since
- 3.0
val minus_one : t
minus_one
is the integer-1
.- since
- 3.0
val abs : t -> t
abs x
is the absolute value ofx
. It isx
ifx
is positive andneg x
otherwise.- since
- 3.0
val max_int : t
max_int
is the maximum integer.- since
- 3.0
val min_int : t
min_int
is the minimum integer.- since
- 3.0
val compare : t -> t -> int
compare x y
is the comparison function for integers with the same specification asStdlib
.compare.
val hash : t -> int
hash x
computes the hash ofx
.
val sign : t -> int
sign x
return0
ifx = 0
,-1
ifx < 0
and1
ifx > 0
. Same ascompare x 0
.
val pow : t -> t -> t
pow base exponent
returnsbase
raised to the power ofexponent
.pow x y = x^y
for positive integersx
andy
. RaisesInvalid_argument
ifx = y = 0
ory
< 0.- since
- 0.11
val floor_div : t -> t -> t
floor_div x n
is integer division rounding towards negative infinity. It satisfiesx = m * floor_div x n + rem x n
.- since
- 1.2
type 'a printer
= Stdlib.Format.formatter -> 'a -> unit
type 'a random_gen
= Stdlib.Random.State.t -> 'a
type 'a iter
= ('a -> unit) -> unit
val random : int -> t random_gen
val random_small : t random_gen
val random_range : int -> int -> t random_gen
val pp : t printer
pp ppf x
prints the integerx
onppf
.
val to_float : t -> float
to_float
is the same asfloat_of_int
- since
- 3.0
val of_float : float -> t
to_float
is the same asint_of_float
- since
- 3.0
val to_string : t -> string
to_string x
returns the string representation of the integerx
, in signed decimal.- since
- 0.13
val of_string : string -> t option
of_string s
converts the given strings
into an integer. Safe version ofof_string_exn
.- since
- 0.13
val of_string_exn : string -> t
of_string_exn s
converts the given strings
to an integer. Alias toint_of_string
.- raises Failure
in case of failure.
- since
- 3.0
val of_float : float -> t
of_float x
converts the given floating-point numberx
to an integer. Alias toint_of_float
.- since
- 3.0
val to_string_binary : t -> string
to_string_binary x
returns the string representation of the integerx
, in binary.- since
- 0.20
val range_by : step:t -> t -> t -> t iter
range_by ~step i j
iterates on integers fromi
toj
included, where the difference between successive elements isstep
. Use a negativestep
for a decreasing list.- raises Invalid_argument
if
step=0
.
- since
- 1.2
val range : t -> t -> t iter
range i j
iterates on integers fromi
toj
included . It works both for decreasing and increasing ranges.- since
- 1.2
val range' : t -> t -> t iter
range' i j
is likerange
but the second boundj
is excluded. For instancerange' 0 5 = Iter.of_list [0;1;2;3;4]
.- since
- 1.2
val popcount : t -> int
Number of bits set to 1
- since
- 3.0
Infix Operators
- since
- 0.17
module Infix : sig ... end