The COMPARE_DECFLOAT function returns an ordering for DECFLOAT values.
The COMPARE_DECFLOAT function returns a small integer value that indicates how expression-1 compares with expression-2.
The first argument is compared with the second argument and the result is returned according to the following rules.
rules
for DECFLOAT subtraction. If the
difference is exactly zero with either sign
and
with the same number of zeroes to the right of the decimal point,
the
arguments are equal. If a nonzero difference is positive, the first
argument is greater than the second argument. If a nonzero difference
is negative, the first argument is less than the second.The result value is set as follows:
| 0 | if the arguments are exactly equal. |
| 1 | if expression-1 is less than expression-2. |
| 2 | if expression-1 is greater than expression-2. |
| 3 | if the arguments are unordered. |
The result of the function is SMALLINT. If either argument can be null, the result can be null; if either argument is null, the result is the null value.
The following examples demonstrate the values that will be returned when the function is used:
COMPARE_DECFLOAT (DECFLOAT(2.17), DECFLOAT(2.17)) = 0
COMPARE_DECFLOAT (DECFLOAT(2.17), DECFLOAT(2.170)) = 2
COMPARE_DECFLOAT (DECFLOAT(2.170), DECFLOAT(2.17)) = 1
COMPARE_DECFLOAT (DECFLOAT(2.17), DECFLOAT(0.0)) = 2
COMPARE_DECFLOAT (INFINITY, INFINITY) = 0
COMPARE_DECFLOAT (INFINITY, -INFINITY) = 2
COMPARE_DECFLOAT (DECFLOAT(-2), INFINITY) = 1
COMPARE_DECFLOAT (NAN, NAN) = 3
COMPARE_DECFLOAT (DECFLOAT(-0.1), SNAN) = 3