.TH "Int32" 3o source: 2019-01-25 OCamldoc "OCaml library" .SH NAME Int32 \- 32-bit integers. .SH Module Module Int32 .SH Documentation .sp Module .BI "Int32" : .B sig end .sp 32\-bit integers\&. .sp This module provides operations on the type .B int32 of signed 32\-bit integers\&. Unlike the built\-in .B int type, the type .B int32 is guaranteed to be exactly 32\-bit wide on all platforms\&. All arithmetic operations over .B int32 are taken modulo 2^{32\&. .sp Performance notice: values of type .B int32 occupy more memory space than values of type .B int , and arithmetic operations on .B int32 are generally slower than those on .B int \&. Use .B int32 only when the application requires exact 32\-bit arithmetic\&. .sp .sp .sp .I val zero : .B int32 .sp The 32\-bit integer 0\&. .sp .I val one : .B int32 .sp The 32\-bit integer 1\&. .sp .I val minus_one : .B int32 .sp The 32\-bit integer \-1\&. .sp .I val neg : .B int32 -> int32 .sp Unary negation\&. .sp .I val add : .B int32 -> int32 -> int32 .sp Addition\&. .sp .I val sub : .B int32 -> int32 -> int32 .sp Subtraction\&. .sp .I val mul : .B int32 -> int32 -> int32 .sp Multiplication\&. .sp .I val div : .B int32 -> int32 -> int32 .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 int32 -> int32 -> int32 .sp Integer remainder\&. If .B y is not zero, the result of .B Int32\&.rem x y satisfies the following property: .B x = Int32\&.add (Int32\&.mul (Int32\&.div x y) y) (Int32\&.rem x y) \&. If .B y = 0 , .B Int32\&.rem x y raises .B Division_by_zero \&. .sp .I val succ : .B int32 -> int32 .sp Successor\&. .B Int32\&.succ x is .B Int32\&.add x Int32\&.one \&. .sp .I val pred : .B int32 -> int32 .sp Predecessor\&. .B Int32\&.pred x is .B Int32\&.sub x Int32\&.one \&. .sp .I val abs : .B int32 -> int32 .sp Return the absolute value of its argument\&. .sp .I val max_int : .B int32 .sp The greatest representable 32\-bit integer, 2^{31 \- 1\&. .sp .I val min_int : .B int32 .sp The smallest representable 32\-bit integer, \-2^{31\&. .sp .I val logand : .B int32 -> int32 -> int32 .sp Bitwise logical and\&. .sp .I val logor : .B int32 -> int32 -> int32 .sp Bitwise logical or\&. .sp .I val logxor : .B int32 -> int32 -> int32 .sp Bitwise logical exclusive or\&. .sp .I val lognot : .B int32 -> int32 .sp Bitwise logical negation .sp .I val shift_left : .B int32 -> int -> int32 .sp .B Int32\&.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 >= 32 \&. .sp .I val shift_right : .B int32 -> int -> int32 .sp .B Int32\&.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 >= 32 \&. .sp .I val shift_right_logical : .B int32 -> int -> int32 .sp .B Int32\&.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 >= 32 \&. .sp .I val of_int : .B int -> int32 .sp Convert the given integer (type .B int ) to a 32\-bit integer (type .B int32 )\&. .sp .I val to_int : .B int32 -> int .sp Convert the given 32\-bit integer (type .B int32 ) to an integer (type .B int )\&. On 32\-bit platforms, the 32\-bit integer is taken modulo 2^{31, i\&.e\&. the high\-order bit is lost during the conversion\&. On 64\-bit platforms, the conversion is exact\&. .sp .I val of_float : .B float -> int32 .sp Convert the given floating\-point number to a 32\-bit 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 Int32\&.min_int , .B Int32\&.max_int ]\&. .sp .I val to_float : .B int32 -> float .sp Convert the given 32\-bit integer to a floating\-point number\&. .sp .I val of_string : .B string -> int32 .sp Convert the given string to a 32\-bit 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 int32 \&. .sp .I val of_string_opt : .B string -> int32 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 int32 -> string .sp Return the string representation of its argument, in signed decimal\&. .sp .I val bits_of_float : .B float -> int32 .sp Return the internal representation of the given float according to the IEEE 754 floating\-point \&'single format\&' bit layout\&. Bit 31 of the result represents the sign of the float; bits 30 to 23 represent the (biased) exponent; bits 22 to 0 represent the mantissa\&. .sp .I val float_of_bits : .B int32 -> float .sp Return the floating\-point number whose internal representation, according to the IEEE 754 floating\-point \&'single format\&' bit layout, is the given .B int32 \&. .sp .I type t = .B int32 .sp An alias for the type of 32\-bit integers\&. .sp .I val compare : .B t -> t -> int .sp The comparison function for 32\-bit integers, with the same specification as .B Pervasives\&.compare \&. Along with the type .B t , this function .B compare allows the module .B Int32 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 int32s\&. .sp .B "Since" 4.03.0 .sp