package hardcaml_fixed_point

  1. Overview
  2. Docs
Hardcaml fixed point arithmetic

Install

Dune Dependency

Authors

Maintainers

Sources

hardcaml_fixed_point-v0.15.0.tar.gz
sha256=aac72d5a89d3a93147781c248436d29db5ee86c93e0fc6c92bab5e0011dde910

Description

Signed and Unsigned fixed point operations, with a full complement of rounding and overflow functionality.

Published: 21 Mar 2022

README

"Fixed point arithmetic types"

hardcaml_fixed_point

A simple fixed point library for Hardcaml.

Numbers are represented in a [I.F] format which provides [I] integer bits and [F] fractional bits. We require [I>0] and [F>=0].

Seperate modules for Signed and Unsigned fixed point numbers are implemented.

The basic arithmetic operators are provided which ensure no overflow is possible and track precision.

Comparisions do not require the same precision for each argument.

The most important function is [resize]. This can increase or decrease [I] and [F]. When increasing appropriate padding is performed. When decreasing [I] the result can either [saturate] or [wrap]. When decreasing [F] a rounding function can be specified:

  • neg_infinity

  • pos_infinity

  • to_zero

  • away_from_zero

  • tie_to_neg_infinity

  • tie_to_pos_infinity

  • tie_to_zero

  • tie_away_from_zero

  • tie_to_nearest_even

  • tie_to_nearest_odd

Note that [wrap] along with rounding to [neg_infinity] is effectively just truncating the top and bottom bits and uses no hardware.

Dependencies (5)

  1. dune >= "2.0.0"
  2. ppx_jane >= "v0.15" & < "v0.16"
  3. hardcaml >= "v0.15" & < "v0.16"
  4. base >= "v0.15" & < "v0.16"
  5. ocaml >= "4.08.0"

Dev Dependencies

None

Used by

None

Conflicts

None

OCaml

Innovation. Community. Security.