.TH "Nativeint" 3o source: 2019-01-25 OCamldoc "OCaml library" .SH NAME Nativeint \- Processor-native integers. .SH Module Module Nativeint .SH Documentation .sp Module .BI "Nativeint" : .B sig end .sp Processor\-native integers\&. .sp This module provides operations on the type .B 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 pointer type in the C compiler\&. All arithmetic operations over .B nativeint are taken modulo 2^{32 or 2^{64 depending on the word size of the architecture\&. .sp Performance notice: values of type .B nativeint occupy more memory space than values of type .B int , and arithmetic operations on .B nativeint are generally slower than those on .B int \&. Use .B nativeint only when the application requires the extra bit of precision over the .B int type\&. .sp .sp .sp .I val zero : .B nativeint .sp The native integer 0\&. .sp .I val one : .B nativeint .sp The native integer 1\&. .sp .I val minus_one : .B nativeint .sp The native integer \-1\&. .sp .I val neg : .B nativeint -> nativeint .sp Unary negation\&. .sp .I val add : .B nativeint -> nativeint -> nativeint .sp Addition\&. .sp .I val sub : .B nativeint -> nativeint -> nativeint .sp Subtraction\&. .sp .I val mul : .B nativeint -> nativeint -> nativeint .sp Multiplication\&. .sp .I val div : .B nativeint -> nativeint -> nativeint .sp Integer division\&. Raise .B Division_by_zero if the second argument is zero\&. This division rounds the real quotient of its arguments towards zero, as specified for .B Pervasives\&.(/) \&. .sp .I val rem : .B nativeint -> nativeint -> nativeint .sp Integer remainder\&. If .B y is not zero, the result of .B Nativeint\&.rem x y satisfies the following properties: .B Nativeint\&.zero <= Nativeint\&.rem x y < Nativeint\&.abs y and .B x = Nativeint\&.add (Nativeint\&.mul (Nativeint\&.div x y) y) .B (Nativeint\&.rem x y) \&. If .B y = 0 , .B Nativeint\&.rem x y raises .B Division_by_zero \&. .sp .I val succ : .B nativeint -> nativeint .sp Successor\&. .B Nativeint\&.succ x is .B Nativeint\&.add x Nativeint\&.one \&. .sp .I val pred : .B nativeint -> nativeint .sp Predecessor\&. .B Nativeint\&.pred x is .B Nativeint\&.sub x Nativeint\&.one \&. .sp .I val abs : .B nativeint -> nativeint .sp Return the absolute value of its argument\&. .sp .I val size : .B int .sp The size in bits of a native integer\&. This is equal to .B 32 on a 32\-bit platform and to .B 64 on a 64\-bit platform\&. .sp .I val max_int : .B nativeint .sp The greatest representable native integer, either 2^{31 \- 1 on a 32\-bit platform, or 2^{63 \- 1 on a 64\-bit platform\&. .sp .I val min_int : .B nativeint .sp The smallest representable native integer, either \-2^{31 on a 32\-bit platform, or \-2^{63 on a 64\-bit platform\&. .sp .I val logand : .B nativeint -> nativeint -> nativeint .sp Bitwise logical and\&. .sp .I val logor : .B nativeint -> nativeint -> nativeint .sp Bitwise logical or\&. .sp .I val logxor : .B nativeint -> nativeint -> nativeint .sp Bitwise logical exclusive or\&. .sp .I val lognot : .B nativeint -> nativeint .sp Bitwise logical negation .sp .I val shift_left : .B nativeint -> int -> nativeint .sp .B Nativeint\&.shift_left x y shifts .B x to the left by .B y bits\&. The result is unspecified if .B y < 0 or .B y >= bitsize , where .B bitsize is .B 32 on a 32\-bit platform and .B 64 on a 64\-bit platform\&. .sp .I val shift_right : .B nativeint -> int -> nativeint .sp .B Nativeint\&.shift_right x y shifts .B x to the right by .B y bits\&. This is an arithmetic shift: the sign bit of .B x is replicated and inserted in the vacated bits\&. The result is unspecified if .B y < 0 or .B y >= bitsize \&. .sp .I val shift_right_logical : .B nativeint -> int -> nativeint .sp .B Nativeint\&.shift_right_logical x y shifts .B x to the right by .B y bits\&. This is a logical shift: zeroes are inserted in the vacated bits regardless of the sign of .B x \&. The result is unspecified if .B y < 0 or .B y >= bitsize \&. .sp .I val of_int : .B int -> nativeint .sp Convert the given integer (type .B int ) to a native integer (type .B nativeint )\&. .sp .I val to_int : .B nativeint -> int .sp Convert the given native integer (type .B nativeint ) to an integer (type .B int )\&. The high\-order bit is lost during the conversion\&. .sp .I val of_float : .B float -> nativeint .sp Convert 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 [ .B Nativeint\&.min_int , .B Nativeint\&.max_int ]\&. .sp .I val to_float : .B nativeint -> float .sp Convert the given native integer to a floating\-point number\&. .sp .I val of_int32 : .B int32 -> nativeint .sp Convert the given 32\-bit integer (type .B int32 ) to a native integer\&. .sp .I val to_int32 : .B nativeint -> int32 .sp Convert the given native integer to a 32\-bit integer (type .B int32 )\&. On 64\-bit platforms, the 64\-bit native integer is taken modulo 2^{32, i\&.e\&. the top 32 bits are lost\&. On 32\-bit platforms, the conversion is exact\&. .sp .I val of_string : .B string -> nativeint .sp Convert the given string to a native integer\&. The string is read in decimal (by default) or in hexadecimal, octal or binary if the string begins with .B 0x , .B 0o or .B 0b respectively\&. Raise .B Failure "int_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 type .B nativeint \&. .sp .I val of_string_opt : .B string -> nativeint option .sp Same as .B of_string , but return .B None instead of raising\&. .sp .B "Since" 4.05 .sp .I val to_string : .B nativeint -> string .sp Return the string representation of its argument, in decimal\&. .sp .I type t = .B nativeint .sp An alias for the type of native integers\&. .sp .I val compare : .B t -> t -> int .sp The comparison function for native integers, with the same specification as .B Pervasives\&.compare \&. Along with the type .B t , this function .B compare allows the module .B Nativeint to be passed as argument to the functors .B Set\&.Make and .B Map\&.Make \&. .sp .I val equal : .B t -> t -> bool .sp The equal function for native ints\&. .sp .B "Since" 4.03.0 .sp