Page
Library
Module
Module type
Parameter
Class
Class type
Source
Stdint.Uint8
SourceThe number of bits used by this integer
Integer division. Raise Division_by_zero
if the second argument is zero. This division rounds the real quotient of its arguments towards zero, as specified for (/)
.
Integer division. Raise Division_by_zero
if the second argument is zero. This division rounds the real quotient of its arguments towards zero, as specified for (/)
.
Integer remainder. If y
is not zero
, the result of rem x y
satisfies the following property: x = add (mul (div x y) y) (rem x y)
. If y = 0
, rem x y
raises Division_by_zero
.
shift_left x y
shifts x
to the left by y
bits. The result is unspecified if y < 0
or y >= bits
.
shift_right x y
shifts x
to the right by y
bits. If this is a signed integer, this is an arithmetic shift: the sign bit of x
is replicated and inserted in the vacated bits. The result is unspecified if y < 0
or y >= bits
. For an unsigned integer, this is identical to shift_right_logical
.
shift_right_logical x y
shifts x
to the right by y
bits. This is a logical shift: zeroes are inserted in the vacated bits regardless if x
is a signed or unsiged integer. The result is unspecified if y < 0
or y >= bits
.
Convert the given native integer (type nativeint
) to an integer (type t
.
Convert the given substring starting at the given offset pos
to an integer of type t
and return the offset. The string is read in decimal (by default) or in hexadecimal, octal or binary if the string begins with 0x
, 0o
or 0b
respectively. Raise Failure "*_of_substring"
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 t
.
Convert the given string to an integer of type t
. The string is read in decimal (by default) or in hexadecimal, octal or binary if the string begins with 0x
, 0o
or 0b
respectively. Raise Failure "*_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 t
.
Return the string representation of its argument, in binary (beginning with 0b
)
Return the string representation of its argument, in octal (beginning with 0o
)
Return the string representation of its argument, in hex (beginning with 0x
)
of_bytes_big_endian buffer offset
creates an integer value of type t
from the buffer buffer
starting at offset offset
. The byte order is interpreted to be big endian. If the buffer does not hold enough bytes for this integer, i.e. if (Bytes.length buffer) < (offset + (bits / 8))
, the function will raise Invalid_argument "index out of bounds"
.
of_bytes_big_endian buffer offset
creates an integer value of type t
from the buffer buffer
starting at offset offset
. The byte order is interpreted to be little endian. If the buffer does not hold enough bytes for this integer, i.e. if (Bytes.length buffer) < (offset + (bits / 8))
, the function will raise Invalid_argument "index out of bounds"
.
to_bytes_big_endian i buffer offset
writes the integer i
to the buffer buffer
starting at offset offset
. The byte order used is big endian. If the buffer does not hold enough bytes, i.e. if (Bytes.length buffer) < (offset + (bits / 8))
, the function will raise Invalid_argument "index out of bounds"
.
to_bytes_little_endian i buffer offset
writes the integer i
to the buffer buffer
starting at offset offset
. The byte order used is little endian. If the buffer does not hold enough bytes, i.e. if (Bytes.length buffer) < (offset + (bits / 8))
, the function will raise Invalid_argument "index out of bounds"
.