Up

Module Decimal

The decimal type alias provides more readable serializations to s-expressions, at the cost of lower precision. For example:


    # sexp_of_decimal 3.000000000001;;
    - : Sexp.t = 3
    # sexp_of_float 3.000000000001;;
    - : Sexp.t = 3.0000000000010000889
    

Also, the decimal sexp-converter will fail when provided with nan or infinity.


    # float_of_sexp (Sexp.Atom "nan");;
    - : float = nan
    # decimal_of_sexp (Sexp.Atom "nan");;
    Exception:
    (Sexplib.Conv.Of_sexp_error (Failure common.ml.Decimal_nan_or_inf) nan).
    

Signature

type t = float
val compare : t -> t -> int
val t_of_sexp : Sexplib.Sexp.t -> t
val sexp_of_t : t -> Sexplib.Sexp.t
val bin_read_t : t Bin_prot.Read.reader
val __bin_read_t__ : (int -> t) Bin_prot.Read.reader
val bin_reader_t : t Bin_prot.Type_class.reader
val bin_size_t : t Bin_prot.Size.sizer
val bin_write_t : t Bin_prot.Write.writer
val bin_writer_t : t Bin_prot.Type_class.writer