.TH "Int" 3o 2023-09-18 OCamldoc "OCaml library" .SH NAME Int \- Integer values. .SH Module Module Int .SH Documentation .sp Module .BI "Int" : .B sig end .sp Integer values\&. .sp Integers are .ft B Sys\&.int_size .ft R bits wide and use two\&'s complement representation\&. All operations are taken modulo 2^ .ft B Sys\&.int_size .ft R \&. They do not fail on overflow\&. .sp .B "Since" 4.08 .sp .sp .sp .PP .SS Integers .PP .I type t = .B int .sp The type for integer values\&. .sp .I val zero : .B int .sp .ft B zero .ft R is the integer .ft B 0 .ft R \&. .sp .I val one : .B int .sp .ft B one .ft R is the integer .ft B 1 .ft R \&. .sp .I val minus_one : .B int .sp .ft B minus_one .ft R is the integer .ft B \-1 .ft R \&. .sp .I val neg : .B int -> int .sp .ft B neg x .ft R is .ft B ~\-x .ft R \&. .sp .I val add : .B int -> int -> int .sp .ft B add x y .ft R is the addition .ft B x + y .ft R \&. .sp .I val sub : .B int -> int -> int .sp .ft B sub x y .ft R is the subtraction .ft B x \- y .ft R \&. .sp .I val mul : .B int -> int -> int .sp .ft B mul x y .ft R is the multiplication .ft B x * y .ft R \&. .sp .I val div : .B int -> int -> int .sp .ft B div x y .ft R is the division .ft B x / y .ft R \&. See .ft B (/) .ft R for details\&. .sp .I val rem : .B int -> int -> int .sp .ft B rem x y .ft R is the remainder .ft B x mod y .ft R \&. See .ft B (mod) .ft R for details\&. .sp .I val succ : .B int -> int .sp .ft B succ x .ft R is .ft B add x 1 .ft R \&. .sp .I val pred : .B int -> int .sp .ft B pred x .ft R is .ft B sub x 1 .ft R \&. .sp .I val abs : .B int -> int .sp .ft B abs x .ft R is the absolute value of .ft B x .ft R \&. That is .ft B x .ft R if .ft B x .ft R is positive and .ft B neg x .ft R if .ft B x .ft R is negative\&. Warning\&. This may be negative if the argument is .ft B Int\&.min_int .ft R \&. .sp .I val max_int : .B int .sp .ft B max_int .ft R is the greatest representable integer, .ft B 2{^[Sys\&.int_size \- 1]} \- 1 .ft R \&. .sp .I val min_int : .B int .sp .ft B min_int .ft R is the smallest representable integer, .ft B \-2{^[Sys\&.int_size \- 1]} .ft R \&. .sp .I val logand : .B int -> int -> int .sp .ft B logand x y .ft R is the bitwise logical and of .ft B x .ft R and .ft B y .ft R \&. .sp .I val logor : .B int -> int -> int .sp .ft B logor x y .ft R is the bitwise logical or of .ft B x .ft R and .ft B y .ft R \&. .sp .I val logxor : .B int -> int -> int .sp .ft B logxor x y .ft R is the bitwise logical exclusive or of .ft B x .ft R and .ft B y .ft R \&. .sp .I val lognot : .B int -> int .sp .ft B lognot x .ft R is the bitwise logical negation of .ft B x .ft R \&. .sp .I val shift_left : .B int -> int -> int .sp .ft B shift_left x n .ft R shifts .ft B x .ft R to the left by .ft B n .ft R bits\&. The result is unspecified if .ft B n < 0 .ft R or .ft B n > .ft R .ft B Sys\&.int_size .ft R \&. .sp .I val shift_right : .B int -> int -> int .sp .ft B shift_right x n .ft R shifts .ft B x .ft R to the right by .ft B n .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 n < 0 .ft R or .ft B n > .ft R .ft B Sys\&.int_size .ft R \&. .sp .I val shift_right_logical : .B int -> int -> int .sp .ft B shift_right x n .ft R shifts .ft B x .ft R to the right by .ft B n .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 n < 0 .ft R or .ft B n > .ft R .ft B Sys\&.int_size .ft R \&. .sp .PP .SS Predicates and comparisons .PP .I val equal : .B int -> int -> bool .sp .ft B equal x y .ft R is .ft B true .ft R if and only if .ft B x = y .ft R \&. .sp .I val compare : .B int -> int -> int .sp .ft B compare x y .ft R is .ft B compare .ft R .ft B x y .ft R but more efficient\&. .sp .I val min : .B int -> int -> int .sp Return the smaller of the two arguments\&. .sp .B "Since" 4.13.0 .sp .I val max : .B int -> int -> int .sp Return the greater of the two arguments\&. .sp .B "Since" 4.13.0 .sp .PP .SS Converting .PP .I val to_float : .B int -> float .sp .ft B to_float x .ft R is .ft B x .ft R as a floating point number\&. .sp .I val of_float : .B float -> int .sp .ft B of_float x .ft R truncates .ft B x .ft R to an integer\&. The result is unspecified if the argument is .ft B nan .ft R or falls outside the range of representable integers\&. .sp .I val to_string : .B int -> string .sp .ft B to_string x .ft R is the written representation of .ft B x .ft R in decimal\&. .sp