.TH "Int64" 3o 2023-09-20 OCamldoc "OCaml library" .SH NAME Int64 \- 64-bit integers. .SH Module Module Int64 .SH Documentation .sp Module .BI "Int64" : .B sig end .sp 64\-bit integers\&. .sp This module provides operations on the type .ft B int64 .ft R of signed 64\-bit integers\&. Unlike the built\-in .ft B int .ft R type, the type .ft B int64 .ft R is guaranteed to be exactly 64\-bit wide on all platforms\&. All arithmetic operations over .ft B int64 .ft R are taken modulo 2^64 .sp Performance notice: values of type .ft B int64 .ft R occupy more memory space than values of type .ft B int .ft R , and arithmetic operations on .ft B int64 .ft R are generally slower than those on .ft B int .ft R \&. Use .ft B int64 .ft R only when the application requires exact 64\-bit arithmetic\&. .sp Literals for 64\-bit integers are suffixed by L: .EX .ft B .br \& let zero: int64 = 0L .br \& let one: int64 = 1L .br \& let m_one: int64 = \-1L .br \& .ft R .EE .sp .sp .sp .I val zero : .B int64 .sp The 64\-bit integer 0\&. .sp .I val one : .B int64 .sp The 64\-bit integer 1\&. .sp .I val minus_one : .B int64 .sp The 64\-bit integer \-1\&. .sp .I val neg : .B int64 -> int64 .sp Unary negation\&. .sp .I val add : .B int64 -> int64 -> int64 .sp Addition\&. .sp .I val sub : .B int64 -> int64 -> int64 .sp Subtraction\&. .sp .I val mul : .B int64 -> int64 -> int64 .sp Multiplication\&. .sp .I val div : .B int64 -> int64 -> int64 .sp Integer division\&. .sp .B "Raises Division_by_zero" if the second argument is zero\&. This division rounds the real quotient of its arguments towards zero, as specified for .ft B (/) .ft R \&. .sp .I val unsigned_div : .B int64 -> int64 -> int64 .sp Same as .ft B Int64\&.div .ft R , except that arguments and result are interpreted as unsigned 64\-bit integers\&. .sp .B "Since" 4.08.0 .sp .I val rem : .B int64 -> int64 -> int64 .sp Integer remainder\&. If .ft B y .ft R is not zero, the result of .ft B Int64\&.rem x y .ft R satisfies the following property: .ft B x = Int64\&.add (Int64\&.mul (Int64\&.div x y) y) (Int64\&.rem x y) .ft R \&. If .ft B y = 0 .ft R , .ft B Int64\&.rem x y .ft R raises .ft B Division_by_zero .ft R \&. .sp .I val unsigned_rem : .B int64 -> int64 -> int64 .sp Same as .ft B Int64\&.rem .ft R , except that arguments and result are interpreted as unsigned 64\-bit integers\&. .sp .B "Since" 4.08.0 .sp .I val succ : .B int64 -> int64 .sp Successor\&. .ft B Int64\&.succ x .ft R is .ft B Int64\&.add x Int64\&.one .ft R \&. .sp .I val pred : .B int64 -> int64 .sp Predecessor\&. .ft B Int64\&.pred x .ft R is .ft B Int64\&.sub x Int64\&.one .ft R \&. .sp .I val abs : .B int64 -> int64 .sp Return the absolute value of its argument\&. .sp .I val max_int : .B int64 .sp The greatest representable 64\-bit integer, 2^63 \- 1\&. .sp .I val min_int : .B int64 .sp The smallest representable 64\-bit integer, \-2^63\&. .sp .I val logand : .B int64 -> int64 -> int64 .sp Bitwise logical and\&. .sp .I val logor : .B int64 -> int64 -> int64 .sp Bitwise logical or\&. .sp .I val logxor : .B int64 -> int64 -> int64 .sp Bitwise logical exclusive or\&. .sp .I val lognot : .B int64 -> int64 .sp Bitwise logical negation\&. .sp .I val shift_left : .B int64 -> int -> int64 .sp .ft B Int64\&.shift_left x y .ft R shifts .ft B x .ft R to the left by .ft B y .ft R bits\&. The result is unspecified if .ft B y < 0 .ft R or .ft B y >= 64 .ft R \&. .sp .I val shift_right : .B int64 -> int -> int64 .sp .ft B Int64\&.shift_right x y .ft R shifts .ft B x .ft R to the right by .ft B y .ft R bits\&. This is an arithmetic shift: the sign bit of .ft B x .ft R is replicated and inserted in the vacated bits\&. The result is unspecified if .ft B y < 0 .ft R or .ft B y >= 64 .ft R \&. .sp .I val shift_right_logical : .B int64 -> int -> int64 .sp .ft B Int64\&.shift_right_logical x y .ft R shifts .ft B x .ft R to the right by .ft B y .ft R bits\&. This is a logical shift: zeroes are inserted in the vacated bits regardless of the sign of .ft B x .ft R \&. The result is unspecified if .ft B y < 0 .ft R or .ft B y >= 64 .ft R \&. .sp .I val of_int : .B int -> int64 .sp Convert the given integer (type .ft B int .ft R ) to a 64\-bit integer (type .ft B int64 .ft R )\&. .sp .I val to_int : .B int64 -> int .sp Convert the given 64\-bit integer (type .ft B int64 .ft R ) to an integer (type .ft B int .ft R )\&. On 64\-bit platforms, the 64\-bit integer is taken modulo 2^63, i\&.e\&. the high\-order bit is lost during the conversion\&. On 32\-bit platforms, the 64\-bit integer is taken modulo 2^31, i\&.e\&. the top 33 bits are lost during the conversion\&. .sp .I val unsigned_to_int : .B int64 -> int option .sp Same as .ft B Int64\&.to_int .ft R , but interprets the argument as an unsigned integer\&. Returns .ft B None .ft R if the unsigned value of the argument cannot fit into an .ft B int .ft R \&. .sp .B "Since" 4.08.0 .sp .I val of_float : .B float -> int64 .sp Convert the given floating\-point number to a 64\-bit integer, discarding the fractional part (truncate towards 0)\&. If the truncated floating\-point number is outside the range [ .ft B Int64\&.min_int .ft R , .ft B Int64\&.max_int .ft R ], no exception is raised, and an unspecified, platform\-dependent integer is returned\&. .sp .I val to_float : .B int64 -> float .sp Convert the given 64\-bit integer to a floating\-point number\&. .sp .I val of_int32 : .B int32 -> int64 .sp Convert the given 32\-bit integer (type .ft B int32 .ft R ) to a 64\-bit integer (type .ft B int64 .ft R )\&. .sp .I val to_int32 : .B int64 -> int32 .sp Convert the given 64\-bit integer (type .ft B int64 .ft R ) to a 32\-bit integer (type .ft B int32 .ft R )\&. The 64\-bit integer is taken modulo 2^32, i\&.e\&. the top 32 bits are lost during the conversion\&. .sp .I val of_nativeint : .B nativeint -> int64 .sp Convert the given native integer (type .ft B nativeint .ft R ) to a 64\-bit integer (type .ft B int64 .ft R )\&. .sp .I val to_nativeint : .B int64 -> nativeint .sp Convert the given 64\-bit integer (type .ft B int64 .ft R ) to a native integer\&. On 32\-bit platforms, the 64\-bit integer is taken modulo 2^32\&. On 64\-bit platforms, the conversion is exact\&. .sp .I val of_string : .B string -> int64 .sp Convert the given string to a 64\-bit integer\&. The string is read in decimal (by default, or if the string begins with .ft B 0u .ft R ) or in hexadecimal, octal or binary if the string begins with .ft B 0x .ft R , .ft B 0o .ft R or .ft B 0b .ft R respectively\&. .sp The .ft B 0u .ft R prefix reads the input as an unsigned integer in the range .ft B [0, 2*Int64\&.max_int+1] .ft R \&. If the input exceeds .ft B Int64\&.max_int .ft R it is converted to the signed integer .ft B Int64\&.min_int + input \- Int64\&.max_int \- 1 .ft R \&. .sp The .ft B _ .ft R (underscore) character can appear anywhere in the string and is ignored\&. .sp .B "Raises Failure" 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 .ft B int64 .ft R \&. .sp .I val of_string_opt : .B string -> int64 option .sp Same as .ft B of_string .ft R , but return .ft B None .ft R instead of raising\&. .sp .B "Since" 4.05 .sp .I val to_string : .B int64 -> string .sp Return the string representation of its argument, in decimal\&. .sp .I val bits_of_float : .B float -> int64 .sp Return the internal representation of the given float according to the IEEE 754 floating\-point \&'double format\&' bit layout\&. Bit 63 of the result represents the sign of the float; bits 62 to 52 represent the (biased) exponent; bits 51 to 0 represent the mantissa\&. .sp .I val float_of_bits : .B int64 -> float .sp Return the floating\-point number whose internal representation, according to the IEEE 754 floating\-point \&'double format\&' bit layout, is the given .ft B int64 .ft R \&. .sp .I type t = .B int64 .sp An alias for the type of 64\-bit integers\&. .sp .I val compare : .B t -> t -> int .sp The comparison function for 64\-bit integers, with the same specification as .ft B compare .ft R \&. Along with the type .ft B t .ft R , this function .ft B compare .ft R allows the module .ft B Int64 .ft R to be passed as argument to the functors .ft B Set\&.Make .ft R and .ft B Map\&.Make .ft R \&. .sp .I val unsigned_compare : .B t -> t -> int .sp Same as .ft B Int64\&.compare .ft R , except that arguments are interpreted as unsigned 64\-bit integers\&. .sp .B "Since" 4.08.0 .sp .I val equal : .B t -> t -> bool .sp The equal function for int64s\&. .sp .B "Since" 4.03.0 .sp .I val min : .B t -> t -> t .sp Return the smaller of the two arguments\&. .sp .B "Since" 4.13.0 .sp .I val max : .B t -> t -> t .sp Return the greater of the two arguments\&. .sp .B "Since" 4.13.0 .sp