Previous Contents Next
19.13 Module Int64: 64-bit integers


This module provides operations on the type int64 of signed 64-bit integers. Unlike the built-in int type, the type int64 is guaranteed to be exactly 64-bit wide on all platforms. All arithmetic operations over int64 are taken modulo 264.

The type int64 is supported on all 64-bit platforms, as well as on all 32-bit platforms for which the C compiler supports 64-bit arithmetic. On 32-bit platforms without support for 64-bit arithmetic, all functions in this module raise an Invalid_argument exception.

Performance notice: values of type int64 occupy more memory space than values of type int, and arithmetic operations on int64 are generally slower than those on int. Use int64 only when the application requires exact 64-bit arithmetic.
val zero : int64
val one : int64
val minus_one : int64
The 64-bit integers 0, 1, -1.
val neg : int64 -> int64
Unary negation.
val add : int64 -> int64 -> int64
Addition.
val sub : int64 -> int64 -> int64
Subtraction.
val mul : int64 -> int64 -> int64
Multiplication.
val div : int64 -> int64 -> int64
Integer division. Raise Division_by_zero if the second argument is zero.
val rem : int64 -> int64 -> int64
Integer remainder. If x >= 0 and y > 0, the result of Int64.rem x y satisfies the following properties: 0 <= Int64.rem x y < y and x = Int64.add (Int64.mul (Int64.div x y) y) (Int64.rem x y). If y = 0, Int64.rem x y raises Division_by_zero. If x < 0 or y < 0, the result of Int64.rem x y is not specified and depends on the platform.
val succ : int64 -> int64
Successor. Int64.succ x is Int64.add x Int64.one.
val pred : int64 -> int64
Predecessor. Int64.pred x is Int64.sub x Int64.one.
val abs : int64 -> int64
Return the absolute value of its argument.
val max_int : int64
The greatest representable 64-bit integer, 263 - 1.
val min_int : int64