val div : nativeint -> nativeint -> nativeintInteger division. Raise
Division_by_zeroif the second argument is zero. This division rounds the real quotient of its arguments towards zero, as specified forStdlib.(/).
val unsigned_div : nativeint -> nativeint -> nativeintSame as
div, except that arguments and result are interpreted as unsigned native integers.- since
- 4.08.0
val rem : nativeint -> nativeint -> nativeintInteger remainder. If
yis not zero, the result ofNativeint.rem x ysatisfies the following properties:Nativeint.zero <= Nativeint.rem x y < Nativeint.abs yandx = Nativeint.add (Nativeint.mul (Nativeint.div x y) y) (Nativeint.rem x y). Ify = 0,Nativeint.rem x yraisesDivision_by_zero.
val unsigned_rem : nativeint -> nativeint -> nativeintSame as
rem, except that arguments and result are interpreted as unsigned native integers.- since
- 4.08.0
val size : intThe size in bits of a native integer. This is equal to
32on a 32-bit platform and to64on a 64-bit platform.
val max_int : nativeintThe greatest representable native integer, either 231 - 1 on a 32-bit platform, or 263 - 1 on a 64-bit platform.
val min_int : nativeintThe smallest representable native integer, either -231 on a 32-bit platform, or -263 on a 64-bit platform.
val shift_left : nativeint -> int -> nativeintNativeint.shift_left x yshiftsxto the left byybits. The result is unspecified ify < 0ory >= bitsize, wherebitsizeis32on a 32-bit platform and64on a 64-bit platform.
val shift_right : nativeint -> int -> nativeintNativeint.shift_right x yshiftsxto the right byybits. This is an arithmetic shift: the sign bit ofxis replicated and inserted in the vacated bits. The result is unspecified ify < 0ory >= bitsize.
val shift_right_logical : nativeint -> int -> nativeintNativeint.shift_right_logical x yshiftsxto the right byybits. This is a logical shift: zeroes are inserted in the vacated bits regardless of the sign ofx. The result is unspecified ify < 0ory >= bitsize.
val of_int : int -> nativeintConvert the given integer (type
int) to a native integer (typenativeint).
val to_int : nativeint -> intConvert the given native integer (type
nativeint) to an integer (typeint). The high-order bit is lost during the conversion.
val unsigned_to_int : nativeint -> int optionSame as
to_int, but interprets the argument as an unsigned integer. ReturnsNoneif the unsigned value of the argument cannot fit into anint.- since
- 4.08.0
val of_float : float -> nativeintConvert the given floating-point number to a native integer, discarding the fractional part (truncate towards 0). The result of the conversion is undefined if, after truncation, the number is outside the range [
Nativeint.min_int,Nativeint.max_int].
val to_int32 : nativeint -> int32Convert the given native integer to a 32-bit integer (type
int32). On 64-bit platforms, the 64-bit native integer is taken modulo 232, i.e. the top 32 bits are lost. On 32-bit platforms, the conversion is exact.
val of_string : string -> nativeintConvert the given string to a native integer. The string is read in decimal (by default, or if the string begins with
0u) or in hexadecimal, octal or binary if the string begins with0x,0oor0brespectively.The
0uprefix reads the input as an unsigned integer in the range[0, 2*Nativeint.max_int+1]. If the input exceedsNativeint.max_intit is converted to the signed integerInt64.min_int + input - Nativeint.max_int - 1.Raise
Failure "Nativeint.of_string"if the given string is not a valid representation of an integer, or if the integer represented exceeds the range of integers representable in typenativeint.
val of_string_opt : string -> nativeint optionSame as
of_string, but returnNoneinstead of raising.- since
- 4.05
val compare : t -> t -> intThe comparison function for native integers, with the same specification as
Stdlib.compare. Along with the typet, this functioncompareallows the moduleNativeintto be passed as argument to the functorsSet.MakeandMap.Make.