Movatterモバイル変換


[0]ホーム

URL:


ModuleInt

module Int:sig..end

Integer values.

Integers areSys.int_size bits wide and use two's complement representation. All operations are taken modulo 2Sys.int_size. They do not fail on overflow.


Integers

typet =int

The type for integer values.

val zero :int

zero is the integer0.

val one :int

one is the integer1.

val minus_one :int

minus_one is the integer-1.

val neg :int -> int

neg x is~-x.

val add :int -> int -> int

add x y is the additionx + y.

val sub :int -> int -> int

sub x y is the subtractionx - y.

val mul :int -> int -> int

mul x y is the multiplicationx * y.

val div :int -> int -> int

div x y is the divisionx / y. See(/) for details.

val rem :int -> int -> int

rem x y is the remaindermod y. See(mod) for details.

val succ :int -> int

succ x isadd x 1.

val pred :int -> int

pred x issub x 1.

val abs :int -> int

abs x is the absolute value ofx. That isx ifx is positive andneg x ifx is negative.Warning. This may be negative if the argument isInt.min_int.

val max_int :int

max_int is the greatest representable integer,2Sys.int_size - 1-1.

val min_int :int

min_int is the smallest representable integer,-2Sys.int_size - 1.

val logand :int -> int -> int

logand x y is the bitwise logical and ofx andy.

val logor :int -> int -> int

logor x y is the bitwise logical or ofx andy.

val logxor :int -> int -> int

logxor x y is the bitwise logical exclusive or ofx andy.

val lognot :int -> int

lognot x is the bitwise logical negation ofx.

val shift_left :int -> int -> int

shift_left x n shiftsx to the left byn bits. The result is unspecified ifn < 0 orn > Sys.int_size.

val shift_right :int -> int -> int

shift_right x n shiftsx to the right byn bits. This is an arithmetic shift: the sign bit ofx is replicated and inserted in the vacated bits. The result is unspecified ifn < 0 orn > Sys.int_size.

val shift_right_logical :int -> int -> int

shift_right x n shiftsx to the right byn bits. This is a logical shift: zeroes are inserted in the vacated bits regardless of the sign ofx. The result is unspecified ifn < 0 orn > Sys.int_size.

Predicates and comparisons

val equal :int -> int -> bool

equal x y istrue if and only ifx = y.

val compare :int -> int -> int

compare x y iscompare x y but more efficient.

val min :int -> int -> int

Return the smaller of the two arguments.

val max :int -> int -> int

Return the greater of the two arguments.

Converting

val to_float :int -> float

to_float x isx as a floating point number.

val of_float :float -> int

of_float x truncatesx to an integer. The result is unspecified if the argument isnan or falls outside the range of representable integers.

val to_string :int -> string

to_string x is the written representation ofx in decimal.

val seeded_hash :int -> int -> int

A seeded hash function for ints, with the same output value asHashtbl.seeded_hash. This function allows this module to be passed as argument to the functorHashtbl.MakeSeeded.

val hash :int -> int

An unseeded hash function for ints, with the same output value asHashtbl.hash. This function allows this module to be passed as argument to the functorHashtbl.Make.


[8]ページ先頭

©2009-2025 Movatter.jp