The comparison functions will return either DEC64_TRUE or DEC64_FALSE.

nan

nan (not-a-number) is a popular but poorly named concept in
floating-point systems. It is a number value that represents numbers that
are undefined or not representable. DEC64 has
72 057 594 037 927 936 possible nan values. When these functions return a
nan value, they will always return DEC64_NULL, the
normal nan, regardless of the input.

Two nan values, DEC64_TRUE and DEC64_FALSE, are reserved for representing boolean values.

The remaining nan values may be used to hold object pointers or
other useful values.

Zero

DEC64 has 255 zero values. DEC64 treats them as if they are all equal to
each other. The only zero value returned from these functions is the normal
zero, DEC64_ZERO, which is the same as the native
int64 zero, 0.

Functions

Rounding is to the nearest value. Ties are rounded away from zero. Integer
division is floored. The result of dec64_modulo has the sign of
the divisor. There is no negative zero.

dec64_abs(number: dec64) returns
absolution: dec64

The absolute value function removes the sign from a number value.

If number is

return

nan

DEC64_NULL

zero

DEC64_ZERO

positive

number

negative

-number

dec64_add(augend: dec64,
addend: dec64) returns sum:
dec64

The add function adds an augend and an addend and
returns the sum. If either is nan, or if the sum is not
representable, then the result is DEC64_NULL.

dec64_ceiling(number: dec64)
returns integer: dec64

The ceiling function returns the smallest integer that is greater than or
equal to the number. If the number is nan,
the result is DEC64_NULL. If the number is zero, the
result is DEC64_ZERO. If the number is an integer,
the result is the number.

dec64_coefficient(number:
dec64) returns coefficient: int64

A DEC64number is made up of two parts:
a coefficient and an exponent.

63 8

7 0

coefficient

exponent

This function returns the coefficient part as an
int64.

dec64_coefficient(DEC64_NULL)

returns 0.

dec64_dec(augend: dec64) returns
difference: dec64

The decrement function subtracts 1 from a number. That can be
faster than

dec64_subtract(augend, DEC64_ONE)

dec64_divide(dividend: dec64,
divisor: dec64) returns quotient: dec64

This function divides the dividend by the divisor.

dec64_exponent(number: dec64)
returns exponent: int64

A DEC64number is made up of two parts:
a coefficient and an exponent.

63 8

7 0

coefficient

exponent

This function returns the exponent part as an int64.

dec64_exponent(nan)

returns -128.

dec64_floor(number: dec64) returns
integer: dec64

Produce the largest integer that is less than or equal to the number. This
is sometimes called the entier function. In the result, the
exponent will be greater than or equal to zero unless it is
DEC64_NULL. Numbers with positive exponents will not be
modified, even if the numbers are outside of the safe integer range.

dec64_half(dividend: dec64) returns
quotient: dec64

Divide a dec64 number by two. This will always be faster than

dec64_divide(dividend, dec64_new(2, 0))

dec64_inc(augend: dec64) returns
sum: dec64

The increment function adds 1 to a number. That can be faster
than

dec64_add(augend, DEC64_ONE)

dec64_int(number: dec64) returns
integer: dec64

Convert the number such that the exponent will be zero, discarding the
fraction part. It will produce nan if the result cannot be
represented in 56 signed bits. This is used to extract an
int56 from a dec64 for bitwise operations. It
accepts a broader range than the safe integer range:

dec64_normal(number: dec64) returns
normalization: dec64

Normalize the number by making the exponent as close to zero as possible
without losing any signficance. Usually normalization is not needed since
it does not materially change the value of a number.

dec64_round(number: dec64,
place: dec64) returns quantization:
dec64

Round the number. Ties are rounded away from zero.

The place determines which decimal place to round to. The place should be between -16 and 16.

place

round to nearest

-2

cent

0

integer

3

thousand

6

million

9

billion

dec64_signum(number: dec64) returns
signature: dec64

If the number is nan, the result is DEC64_NULL.
If the number is less than zero, the result is
DEC64_NEGATIVE_ONE. If the number is zero, the result is
DEC64_ZERO. If the number is greater than zero, the result is
DEC64_ONE.