package orsetto

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Utility functions for safe operations with byte-order sensitive data.

Overview

Ancillary internal functions used to check the validity of numeric quantity and octet sequence subrange parameters in the Cf_endian interface.

Signatures
module type Unsafe = sig ... end

The functions in this module offer fast unsafe operations that provide correct behavior only when the parameters are valid, i.e. when the position and length are valid for the string or byte sequence, and when integer and float quantities can converted between representations without error.

module type Safe = sig ... end

This module type defines octet encoding and decoding schemes for the various integer and floating point types.

Modules
module Unsafe_octet : sig ... end

Include this module to include operations single-octet types.

module Safe (U : Unsafe) : Safe

Use this functor to construct safe encoders and decoders.

exception Imprecise

Exception raised when conversion to binary16 or binary32 truncates the fractional part or overflows the exponent.

val is_nan : float -> bool

Use is_nan n to test whether n is not a number.

val of_fp16_bits : int -> float

Use of_fp16_bits n to convert a binary16 format integer representation of IEEE-754 "half-precision" floating point number.

val to_fp16_bits : float -> int

Use to_fp16_bits n to convert a floating point number into its binary16 format integer representation of IEEE-754 "half-precision" floating point. Raises Imprecise if conversion truncates the fractional part or overflows the exponent.

val to_fp32_bits : float -> int32

Use to_fp32_bits n to convert a floating point number into its binary32 format integer representation of IEEE-754 "single-precision" floating point. Raises Imprecise if conversion truncates the fractional part or overflows the exponent.

val to_fp16_bits_unsafe : float -> int

Use to_fp16_bits n to convert a floating point number into its binary16 format integer representation of IEEE-754 "half-precision" floating point. Fractional bits beyond the first ten are truncated. If the exponent is out of range, then infinity is returned. If n = nan then result is the distinguished binary16 form of a signaling NaN.

val to_fp32_bits_unsafe : float -> int32

Use to_fp32_bits n to convert a floating point number into its binary32 format integer representation of IEEE-754 "single-precision" floating point. Fractional bits beyond the first ten are truncated. If the exponent is out of range, then infinity is returned. If n = nan then result is the distinguished binary32 form of a signaling NaN.