package decimal

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

decimal

Arbitrary-precision floating-point decimal type implemented in OCaml. Ported from Python decimal module. It uses Zarith to do biginteger arithmetic.

License

This package is licensed under the Python Software Foundation License v2, for the sake of simplicity, as it is a derived work of the Python decimal module.

Examples

    # (* for convenience *)
  module D = Decimal
  let i = D.of_int
  let s = D.of_string;;
# (* tell the REPL how to display decimals *)
  #install_printer D.pp;;
#
  D.(s "0.1" + s "0.2");;
- : D.t = 0.3
# (* default precision is 32 *)
  D.(i 1 / i 3);;
- : D.t = 0.33333333333333333333333333333333
OCaml

Innovation. Community. Security.