Ion Fusion Documentation
Release 0.38a1-SNAPSHOT (2026-04-16T19:45:37.790Z)

Module /fusion/experimental/decimal

Experimental operators for decimal arithmetic.

WARNING

This module contains unstable, experimental features. There is NO SUPPORT for this module.

decimal_divide procedure
(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 procedure
(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 procedure
(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 procedure
(decimal_scale d)

Returns the number of fractional digits of the decimal d; that is, the negation of the value's exponent.

decimal_to_string procedure

Converts a decimal to a string using Ion notation. Returns null.string when given null.decimal.

string_to_decimal procedure

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).