compare

Compares two operands numerically to the current precision.

Note: The operands are rounded before they are compared. This may result in unexpected results. For instance, if both operands are too large (small) for the context they will both be rounded to infinity (zero) and the function will return 0, indicating that they are equal, even though they are numerically different before rounding.

To compare numbers without rounding, use compareTotal.

int
compare
(
D
)
(
in D left
,
in D right
,
Context context = D.context
)

Return Value

Type: int

-1, 0, or +1 if the second operand is, respectively, less than, equal to, or greater than the first operand.

Meta

Standards

Implements the 'compare' function in the specification. (p. 27)

Flags: INVALID_OPERATION