Int(3) OCaml library Int(3)

# [NAME](#NAME)

Int - Integer values.

# [Module](#Module)

Module Int

# [Documentation](#Documentation)

Module **Int**  
: **sig end**

Integer values.

Integers are **Sys.int\_size** bits wide and use two's complement representation. All operations are taken modulo 2^ **Sys.int\_size** . They do not fail on overflow.

**Since** 4.08

## [Integers](#Integers)

*type t* = **int**

The type for integer values.

*val zero* : **int**

**zero** is the integer **0** .

*val one* : **int**

**one** is the integer **1** .

*val minus\_one* : **int**

**minus\_one** is the integer **-1** .

*val neg* : **int -&gt; int**

**neg x** is **~-x** .

*val add* : **int -&gt; int -&gt; int**

**add x y** is the addition **x + y** .

*val sub* : **int -&gt; int -&gt; int**

**sub x y** is the subtraction **x - y** .

*val mul* : **int -&gt; int -&gt; int**

**mul x y** is the multiplication **x * y** .

*val div* : **int -&gt; int -&gt; int**

**div x y** is the division **x / y** . See **(/)** for details.

*val rem* : **int -&gt; int -&gt; int**

**rem x y** is the remainder **x mod y** . See **(mod)** for details.

*val succ* : **int -&gt; int**

**succ x** is **add x 1** .

*val pred* : **int -&gt; int**

**pred x** is **sub x 1** .

*val abs* : **int -&gt; int**

**abs x** is the absolute value of **x** . That is **x** if **x** is positive and **neg x** if **x** is negative. Warning. This may be negative if the argument is **Int.min\_int** .

*val max\_int* : **int**

**max\_int** is the greatest representable integer, **2{^\[Sys.int\_size - 1]} - 1** .

*val min\_int* : **int**

**min\_int** is the smallest representable integer, **-2{^\[Sys.int\_size - 1]}** .

*val logand* : **int -&gt; int -&gt; int**

**logand x y** is the bitwise logical and of **x** and **y** .

*val logor* : **int -&gt; int -&gt; int**

**logor x y** is the bitwise logical or of **x** and **y** .

*val logxor* : **int -&gt; int -&gt; int**

**logxor x y** is the bitwise logical exclusive or of **x** and **y** .

*val lognot* : **int -&gt; int**

**lognot x** is the bitwise logical negation of **x** .

*val shift\_left* : **int -&gt; int -&gt; int**

**shift\_left x n** shifts **x** to the left by **n** bits. The result is unspecified if **n &lt; 0** or **n &gt;** **Sys.int\_size** .

*val shift\_right* : **int -&gt; int -&gt; int**

**shift\_right x n** shifts **x** to the right by **n** bits. This is an arithmetic shift: the sign bit of **x** is replicated and inserted in the vacated bits. The result is unspecified if **n &lt; 0** or **n &gt;** **Sys.int\_size** .

*val shift\_right\_logical* : **int -&gt; int -&gt; int**

**shift\_right x n** shifts **x** to the right by **n** bits. This is a logical shift: zeroes are inserted in the vacated bits regardless of the sign of **x** . The result is unspecified if **n &lt; 0** or **n &gt;** **Sys.int\_size** .

## [Predicates and comparisons](#Predicates_and_comparisons)

*val equal* : **int -&gt; int -&gt; bool**

**equal x y** is **true** if and only if **x = y** .

*val compare* : **int -&gt; int -&gt; int**

**compare x y** is **compare** **x y** but more efficient.

*val min* : **int -&gt; int -&gt; int**

Return the smaller of the two arguments.

**Since** 4.13.0

*val max* : **int -&gt; int -&gt; int**

Return the greater of the two arguments.

**Since** 4.13.0

## [Converting](#Converting)

*val to\_float* : **int -&gt; float**

**to\_float x** is **x** as a floating point number.

*val of\_float* : **float -&gt; int**

**of\_float x** truncates **x** to an integer. The result is unspecified if the argument is **nan** or falls outside the range of representable integers.

*val to\_string* : **int -&gt; string**

**to\_string x** is the written representation of **x** in decimal.

2026-09-15 OCamldoc

---

Document: Int(3o) from ocaml-4 4.14.4-r3 (Chainguard OS)
Source: https://github.com/ocaml/ocaml
