Previous Contents Next
19.19 Module Nativeint: processor-native integers


This module provides operations on the type nativeint of signed 32-bit integers (on 32-bit platforms) or signed 64-bit integers (on 64-bit platforms). This integer type has exactly the same width as that of a long integer type in the C compiler. All arithmetic operations over nativeint are taken modulo 232 or 264 depending on the word size of the architecture.

Performance notice: values of type nativeint occupy more memory space than values of type int, and arithmetic operations on nativeint are generally slower than those on int. Use nativeint only when the application requires the extra bit of precision over the int type.
val zero: nativeint
val one: nativeint
val minus_one: nativeint
The native integers 0, 1, -1.
val neg: nativeint -> nativeint
Unary negation.
val add: nativeint -> nativeint -> nativeint
Addition.
val sub: nativeint -> nativeint -> nativeint
Subtraction.
val mul: nativeint -> nativeint -> nativeint
Multiplication.
val div: nativeint -> nativeint -> nativeint
Integer division. Raise Division_by_zero if the second argument is zero.
val rem: nativeint -> nativeint -> nativeint
Integer remainder. If x >= 0 and y > 0, the result of Nativeint.rem x y satisfies the following properties: 0 <= Nativeint.rem x y < y and x = Nativeint.add (Nativeint.mul (Nativeint.div x y) y) (Nativeint.rem x y). If y = 0, Nativeint.rem x y raises Division_by_zero. If x < 0 or y < 0, the result of Nativeint.rem x y is not specified and depends on the platform.
val succ: nativeint -> nativeint
Successor. Nativeint.succ x is Nativeint.add x Nativeint.one.
val pred: nativeint -> nativeint
Predecessor. Nativeint.pred x is Nativeint.sub x Nativeint.one.
val abs: nativeint -> nativeint
Return the absolute value of its argument.
val size: int
The size in bits of a native integer. This is equal to 32 on a 32-bit platform and to 64<