Module /fusion/experimental/decimal
Experimental operators for decimal arithmetic.
WARNING
This module contains unstable, experimental features. There is NO SUPPORT for this module.
Exported Bindings
(decimal_divide dividend divisor)
Like /, but rounds to 34 significant digits, using the "half-even" method.
This is equivalent to the "decimal128" default context of IEEE 754.
In the future this procedure will be replaced with a programmatic math context.
(decimal_divide_rescale dividend divisor scale)
Like /, but rounds to scale fractional digits, using the "half-even"
method. dividend and divisor must be decimals, and scale must be an int.
This function is similar to:
(decimal_rescale (decimal_divide dividend divisor) scale)
except only a single rounding operation occurs.
(decimal_rescale d scale)
Returns a decimal whose value is d but rounded to (or extended to) scale
fractional digits. If the scale is reduced (that is, fractional digits are
removed), the value is rounded using the "half-even" method.
d must be a decimal, and scale must be an int.
(decimal_scale d)
Returns the number of fractional digits of the decimal d; that is, the
negation of the value's exponent.
Converts a decimal to a string using Ion notation.
Returns null.string when given null.decimal.
Returns the decimal equivalent of a properly formatted string value. Returns
null.decimal when given null.string.
The string can contain an optional minus sign ("-" aka "\x2D") and must
be followed by one or more ASCII digits. An exception is raised if the string is
a format which cannot be interpreted as a decimal value.
Note: This implementation is experimental! It relies on Java's BigDecimal
API to perform string -> decimal parsing. This means it will not handle
Ion's decimal exponent notation.
It also will (incorrectly) accept the
Java BigDecimal exponent notation).