This module provides access to decimal numbers. Among the ordinary access to decimal numbers that is available both for unlimited and limited precision decimal numbers, we also find access that is specific to limited precision decimal numbers. A decimal number is represented as follows according to the Java BigDecimal class:
D = V * U * 10^(-S)
V : The sign, -1, 0 or 1
U : The unscaled value from the Java BigInteger class.
S : The scale from the Java int class.
For limited precision decimal numbers the order of magnitude of the unscaled value is de-termined as well. This is called the precision of the decimal number and it is independent of the scale of the decimal number. During limited precision arithmetic the precision is limited by a requested precision from a math context:
10^(P-1) <= U < 10^P
P : The precision
The evaluable functions scale/2, unscaled_value/2 and new_decimal/3 allow accessing and creating an unlimited or limited decimal number. The evaluable functions precision/2 and requested/2 allow accessing the current precision of a decimal number and the requested precision through a math context.
The following elementary evaluable functions are provided: