# Module scale

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:

- scale(X, S):
- Predicate succeeds in S with the scale of the decimal number
X.
- unscaled_value(X, U):
- Predicate succeeds in U with the unscaled value of the decimal
number X.
- new_decimal(U, S, D):
- The predicate succeeds in D with a decimal of unscaled value U
and scale S.
- precision(X, P):
- Predicate succeeds in P with the precision of the decimal
number X.
- requested(C, P):
- Predicate succeeds in P with requested precision by the math
context C.
- new_context(P, C):
- Predicate succeeds in C with a new math context of requested
precision P.

## Comments