package containers

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module CCIntSource

Basic Int functions

Integers

Predicates and comparisons

Converting

Sourceval seeded_hash : int -> int -> int

A seeded hash function for ints, with the same output value as Hashtbl.seeded_hash. This function allows this module to be passed as argument to the functor Hashtbl.MakeSeeded.

  • since 5.1
Sourcetype t = int
Sourceval zero : t

zero is the integer 0.

  • since 3.0
Sourceval one : t

one is the integer 1.

  • since 3.0
Sourceval minus_one : t

minus_one is the integer -1.

  • since 3.0
Sourceval add : t -> t -> t

add x y is x + y.

  • since 3.0
Sourceval sub : t -> t -> t

sub x y is x - y.

  • since 3.0
Sourceval mul : t -> t -> t

mul x y is x * y.

  • since 3.0
Sourceval div : t -> t -> t

div x y is x / y

  • since 3.0
Sourceval succ : t -> t

succ x is x + 1.

  • since 3.0
Sourceval pred : t -> t

pred x is x - 1.

  • since 3.0
Sourceval abs : t -> t

abs x is the absolute value of x. It is x if x is positive and neg x otherwise.

  • since 3.0
Sourceval max_int : t

max_int is the maximum integer.

  • since 3.0
Sourceval min_int : t

min_int is the minimum integer.

  • since 3.0
Sourceval compare : t -> t -> int

compare x y is the comparison function for integers with the same specification as Stdlib.compare.

Sourceval equal : t -> t -> bool

equal x y is true iff x and y are equal. Equality function for integers.

Sourceval hash : t -> int

hash x computes the hash of x.

Sourceval sign : t -> int

sign x return 0 if x = 0, -1 if x < 0 and 1 if x > 0. Same as compare x 0.

Sourceval neg : t -> t

neg x is - x. Unary negation.

  • since 0.5
Sourceval pow : t -> t -> t

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.

  • since 0.11
Sourceval floor_div : t -> t -> t

floor_div x n is integer division rounding towards negative infinity. It satisfies x = m * floor_div x n + rem x n.

  • since 1.2
Sourceval rem : t -> t -> t

rem x n is the remainder of dividing x by n, with the same sign as n.

  • since 1.2
Sourcetype 'a printer = Format.formatter -> 'a -> unit
Sourcetype 'a random_gen = Random.State.t -> 'a
Sourcetype 'a iter = ('a -> unit) -> unit
Sourceval random : int -> t random_gen
Sourceval random_small : t random_gen
Sourceval random_range : int -> int -> t random_gen
Sourceval pp : t printer

pp ppf x prints the integer x on ppf.

Sourceval to_float : t -> float

to_float is the same as float_of_int

  • since 3.0
Sourceval to_string : t -> string

to_string x returns the string representation of the integer x, in signed decimal.

  • since 0.13
Sourceval of_string : string -> t option

of_string s converts the given string s into an integer. Safe version of of_string_exn.

  • since 0.13
Sourceval of_string_exn : string -> t

of_string_exn s converts the given string s to an integer. Alias to int_of_string.

  • since 3.0
Sourceval of_float : float -> t

of_float x converts the given floating-point number x to an integer. Alias to int_of_float.

  • since 3.0
Sourceval pp_binary : t printer

pp_binary ppf x prints x on ppf. Print as "0b00101010".

  • since 0.20
Sourceval to_string_binary : t -> string

to_string_binary x returns the string representation of the integer x, in binary.

  • since 0.20
Sourceval min : t -> t -> t

min x y returns the minimum of the two integers x and y.

  • since 0.17
Sourceval max : t -> t -> t

max x y returns the maximum of the two integers x and y.

  • since 0.17
Sourceval range_by : step:t -> t -> t -> t iter

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.

  • since 1.2
Sourceval range : t -> t -> t iter

range i j iterates on integers from i to j included . It works both for decreasing and increasing ranges.

  • since 1.2
Sourceval range' : t -> t -> t iter

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].

  • since 1.2
Sourceval popcount : t -> int

Number of bits set to 1

  • since 3.0
Sourceval logand : t -> t -> t

logand is the same as (land).

  • since 3.0
Sourceval logor : t -> t -> t

logand is the same as (lor).

  • since 3.0
Sourceval logxor : t -> t -> t

logxor is the same as (lxor).

  • since 3.0
Sourceval lognot : t -> t

logand is the same as lnot.

  • since 3.0
Sourceval shift_left : t -> int -> t

shift_left is the same as (lsl).

  • since 3.0
Sourceval shift_right : t -> int -> t

shift_right is the same as (asr).

  • since 3.0
Sourceval shift_right_logical : t -> int -> t

shift_right_logical is the same as (lsr).

  • since 3.0

Infix Operators

  • since 0.17
Sourcemodule Infix : sig ... end
include module type of Infix
Sourceval (=) : t -> t -> bool
  • since 0.17
Sourceval (<>) : t -> t -> bool
  • since 0.17
Sourceval (<) : t -> t -> bool
  • since 0.17
Sourceval (>) : t -> t -> bool
  • since 0.17
Sourceval (<=) : t -> t -> bool
  • since 0.17
Sourceval (>=) : t -> t -> bool
  • since 0.17
Sourceval (--) : t -> t -> t iter

Alias to range.

  • since 1.2
Sourceval (--^) : t -> t -> t iter

Alias to range'.

  • since 1.2
Sourceval (+) : t -> t -> t
  • since 2.1
Sourceval (-) : t -> t -> t
  • since 2.1
Sourceval (~-) : t -> t
  • since 2.1
Sourceval (*) : t -> t -> t
  • since 2.1
Sourceval (/) : t -> t -> t
  • since 2.1
Sourceval (**) : t -> t -> t
  • since 2.4
Sourceval (mod) : t -> t -> t
  • since 2.1
Sourceval (land) : t -> t -> t
  • since 2.1
Sourceval (lor) : t -> t -> t
  • since 2.1
Sourceval (lxor) : t -> t -> t
  • since 2.1
Sourceval lnot : t -> t
  • since 2.1
Sourceval (lsl) : t -> int -> t
  • since 2.1
Sourceval (lsr) : t -> int -> t
  • since 2.1
Sourceval (asr) : t -> int -> t
  • since 2.1
OCaml

Innovation. Community. Security.