module Decimal: sig end
A decimal number is represented internally in base 10 and
characterized by its precision (i.e., its total number of digits)
and its scale. For example, 103.12 has precision 5 (or more) and
scale 2. In this implementation, the precision is taken as
+infinity and the scale adapts dynamically.
type
t
val to_string : t -> string
to_string n
returns a string representation of the decimal
number n
.val to_float : t -> float
to_float n
returns the closer float to n
.val of_string : ?scale:int -> string -> t
of_string ?scale s
returns the decimal number represented by
the string s
. If the option scale
is not set, the scale
will be the one of the string representation. If scale
is
given, it will be enforced, possibly truncating the number.Invalid_argument
if scale < 0
.val of_int : ?scale:int -> int -> t
of_int ?scale i
returns the decimal number i * 10**(-scale)
.Invalid_argument
if scale < 0
.scale
: Scaling of i
(default: 0).val add : t -> t -> t
add n m
returns the sum of n
and m
.val sub : t -> t -> t
sub n m
returns the difference of n
by m
.val mul : t -> t -> t
mul n m
returns the product of n
and m
.val div : t -> t -> t
div n m
returns the division of n
by m
.val compare : t -> t -> int
compare n m
returns 0
if x=y
, a negative integer if
x<y
, and a positive integer if x>y
.