package stdint

  1. Overview
  2. Docs

Module Stdint.Uint8Source

Sourcetype t = uint8

The specific integer type

Constants
Sourceval zero : t

The value 0

Sourceval one : t

The value 1

Sourceval max_int : t

The greatest representable integer

Sourceval min_int : t

The smallest representable integer; for unsigned integers this is zero.

Sourceval bits : int

The number of bits used by this integer

Infix operations
Sourceval (+) : t -> t -> t

Addition

Sourceval (-) : t -> t -> t

Subtraction

Sourceval (*) : t -> t -> t

Multiplication

Sourceval (/) : t -> t -> t

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 (/).

Arithmetic operations
Sourceval add : t -> t -> t

Addition

Sourceval sub : t -> t -> t

Subtraction

Sourceval mul : t -> t -> t

Multiplication

Sourceval div : t -> t -> t

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 (/).

Sourceval rem : t -> t -> t

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.

Sourceval succ : t -> t

Successor. succ x is add x one.

Sourceval pred : t -> t

Predecessor. pred x is sub x one.

Sourceval abs : t -> t

Return the absolute value of its argument.

Sourceval neg : t -> t
Bitiwse operations
Sourceval logand : t -> t -> t

Bitwise logical and.

Sourceval logor : t -> t -> t

Bitwise logical or.

Sourceval logxor : t -> t -> t

Bitwise logical exclusive or.

Sourceval lognot : t -> t

Bitwise logical negation.

Sourceval shift_left : t -> int -> t

shift_left x y shifts x to the left by y bits. The result is unspecified if y < 0 or y >= bits.

Sourceval shift_right : t -> int -> t

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.

Sourceval shift_right_logical : t -> int -> t

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.

Numeric conversion functions
Sourceval of_int : int -> t

Convert the given integer (type int) to this integer type.

Sourceval to_int : t -> int

Convert the given integer (type t) to an integer of type int.

Sourceval of_float : float -> t

Convert the given floating-point number to an integer of type t.

Sourceval to_float : t -> float

Convert the given integer to a floating-point number.

Sourceval of_nativeint : nativeint -> t

Convert the given integer (type t) to a native integer.

Sourceval to_nativeint : t -> nativeint

Convert the given native integer (type nativeint) to an integer (type t.

Sourceval of_int8 : int8 -> t

Convert an integer of type int8 to an integer of type t.

Sourceval to_int8 : t -> int8

Convert an integer of type t to an integer of type int8.

Sourceval of_int16 : int16 -> t

Convert an integer of type int16 to an integer of type t.

Sourceval to_int16 : t -> int16

Convert an integer of type t to an integer of type int16.

Sourceval of_int24 : int24 -> t

Convert an integer of type int24 to an integer of type t.

Sourceval to_int24 : t -> int24

Convert an integer of type t to an integer of type int24.

Sourceval of_int32 : int32 -> t

Convert an integer of type int32 to an integer of type t.

Sourceval to_int32 : t -> int32

Convert an integer of type t to an integer of type int32.

Sourceval of_int40 : int40 -> t

Convert an integer of type int40 to an integer of type t.

Sourceval to_int40 : t -> int40

Convert an integer of type t to an integer of type int40.

Sourceval of_int48 : int48 -> t

Convert an integer of type int48 to an integer of type t.

Sourceval to_int48 : t -> int48

Convert an integer of type t to an integer of type int48.

Sourceval of_int56 : int56 -> t

Convert an integer of type int56 to an integer of type t.

Sourceval to_int56 : t -> int56

Convert an integer of type t to an integer of type int56.

Sourceval of_int64 : int64 -> t

Convert an integer of type int64 to an integer of type t.

Sourceval to_int64 : t -> int64

Convert an integer of type t to an integer of type int64.

Sourceval of_int128 : int128 -> t

Convert an integer of type int128 to an integer of type t.

Sourceval to_int128 : t -> int128

Convert an integer of type t to an integer of type int128.

Sourceval of_uint8 : uint8 -> t

Convert an integer of type uint8 to an integer of type t.

Sourceval to_uint8 : t -> uint8

Convert an integer of type t to an integer of type uint8.

Sourceval of_uint16 : uint16 -> t

Convert an integer of type uint16 to an integer of type t.

Sourceval to_uint16 : t -> uint16

Convert an integer of type t to an integer of type uint16.

Sourceval of_uint24 : uint24 -> t

Convert an integer of type uint24 to an integer of type t.

Sourceval to_uint24 : t -> uint24

Convert an integer of type t to an integer of type uint24.

Sourceval of_uint32 : uint32 -> t

Convert an integer of type uint32 to an integer of type t.

Sourceval to_uint32 : t -> uint32

Convert an integer of type t to an integer of type uint32.

Sourceval of_uint40 : uint40 -> t

Convert an integer of type uint40 to an integer of type t.

Sourceval to_uint40 : t -> uint40

Convert an integer of type t to an integer of type uint40.

Sourceval of_uint48 : uint48 -> t

Convert an integer of type uint48 to an integer of type t.

Sourceval to_uint48 : t -> uint48

Convert an integer of type t to an integer of type uint48.

Sourceval of_uint56 : uint56 -> t

Convert an integer of type uint56 to an integer of type t.

Sourceval to_uint56 : t -> uint56

Convert an integer of type t to an integer of type uint56.

Sourceval of_uint64 : uint64 -> t

Convert an integer of type uint64 to an integer of type t.

Sourceval to_uint64 : t -> uint64

Convert an integer of type t to an integer of type uint64.

Sourceval of_uint128 : uint128 -> t

Convert an integer of type uint128 to an integer of type t.

Sourceval to_uint128 : t -> uint128

Convert an integer of type t to an integer of type uint128.

String conversion functions
Sourceval of_substring : string -> pos:int -> t * int

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.

Sourceval of_string : string -> 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.

Sourceval to_string : t -> string

Return the string representation of its argument, in decimal.

Sourceval to_string_bin : t -> string

Return the string representation of its argument, in binary (beginning with 0b)

Sourceval to_string_oct : t -> string

Return the string representation of its argument, in octal (beginning with 0o)

Sourceval to_string_hex : t -> string

Return the string representation of its argument, in hex (beginning with 0x)

Sourceval printer : Format.formatter -> t -> unit
Sourceval printer_bin : Format.formatter -> t -> unit
Sourceval printer_oct : Format.formatter -> t -> unit
Sourceval printer_hex : Format.formatter -> t -> unit
Raw bytes conversion functions
Sourceval of_bytes_big_endian : Bytes.t -> int -> t

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".

Sourceval of_bytes_little_endian : Bytes.t -> int -> t

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".

Sourceval to_bytes_big_endian : t -> Bytes.t -> int -> unit

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".

Sourceval to_bytes_little_endian : t -> Bytes.t -> int -> unit

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".

Comparison function
Sourceval compare : t -> t -> int

The comparison function for integers of type t, with the same specification as compare. Along with the type t, this function compare allows this module to be passed as argument to the functors Set.Make and Map.Make.

OCaml

Innovation. Community. Security.