Ocamlnet 4 Reference Manual : Netnumber.ENCDEC

# Module type Netnumber.ENCDEC

    module type ENCDEC = sig .. end

Encode/decode numbers as strings. These functions exist in two flavors:

- `Netnumber.BE` implements network byte order (big endian)
- `Netnumber.LE` implements little endian

    val read_int4 : Bytes.t -> int -> Netnumber.int4

    val read_int8 : Bytes.t -> int -> Netnumber.int8

    val read_uint4 : Bytes.t -> int -> Netnumber.uint4

    val read_uint8 : Bytes.t -> int -> Netnumber.uint8

`read_`<t> create integer values from the characters found at a certain position in the string. Raises `Out_of_range` if the position is bad

    val read_int4_unsafe : Bytes.t -> int -> Netnumber.int4

    val read_int8_unsafe : Bytes.t -> int -> Netnumber.int8

    val read_uint4_unsafe : Bytes.t -> int -> Netnumber.uint4

    val read_uint8_unsafe : Bytes.t -> int -> Netnumber.uint8

Same, but no index check

    val read_string_int4 : string -> int -> Netnumber.int4

    val read_string_int8 : string -> int -> Netnumber.int8

    val read_string_uint4 : string -> int -> Netnumber.uint4

    val read_string_uint8 : string -> int -> Netnumber.uint8

    val read_string_int4_unsafe : string -> int -> Netnumber.int4

    val read_string_int8_unsafe : string -> int -> Netnumber.int8

    val read_string_uint4_unsafe : string -> int -> Netnumber.uint4

    val read_string_uint8_unsafe : string -> int -> Netnumber.uint8

For immutable strings

    val write_int4 : Bytes.t -> int -> Netnumber.int4 -> unit

    val write_int8 : Bytes.t -> int -> Netnumber.int8 -> unit

    val write_uint4 : Bytes.t -> int -> Netnumber.uint4 -> unit

    val write_uint8 : Bytes.t -> int -> Netnumber.uint8 -> unit

`write_`<t> copies the characters corresponding to the integer values into the string at the given positions. Raises `Out_of_range` if the position is bad.

    val write_int4_unsafe : Bytes.t -> int -> Netnumber.int4 -> unit

    val write_int8_unsafe : Bytes.t -> int -> Netnumber.int8 -> unit

    val write_uint4_unsafe : Bytes.t -> int -> Netnumber.uint4 -> unit

    val write_uint8_unsafe : Bytes.t -> int -> Netnumber.uint8 -> unit

`write_`<t>`_unsafe`: Same, but no index check.

    val int4_as_bytes : Netnumber.int4 -> Bytes.t

    val int8_as_bytes : Netnumber.int8 -> Bytes.t

    val uint4_as_bytes : Netnumber.uint4 -> Bytes.t

    val uint8_as_bytes : Netnumber.uint8 -> Bytes.t

<t>`_as_bytes`: Returns the corresponding bytes for an integer value

    val int4_as_string : Netnumber.int4 -> string

    val int8_as_string : Netnumber.int8 -> string

    val uint4_as_string : Netnumber.uint4 -> string

    val uint8_as_string : Netnumber.uint8 -> string

<t>`_as_string`: Returns the corresponding string for an integer value

    val write_fp4 : Bytes.t -> int -> Netnumber.fp4 -> unit

    val write_fp8 : Bytes.t -> int -> Netnumber.fp8 -> unit

    val fp4_as_string : Netnumber.fp4 -> string

    val fp8_as_string : Netnumber.fp8 -> string

    val fp4_as_bytes : Netnumber.fp4 -> Bytes.t

    val fp8_as_bytes : Netnumber.fp8 -> Bytes.t

    val read_fp4 : Bytes.t -> int -> Netnumber.fp4

    val read_fp8 : Bytes.t -> int -> Netnumber.fp8

    val read_string_fp4 : string -> int -> Netnumber.fp4

    val read_string_fp8 : string -> int -> Netnumber.fp8