cmp

Defines a total order on all _decimal values.

int
cmp
(
D1
D2
)
(
auto const ref D1 x
,
auto const ref D2 y
)
if (
isDecimal!(D1, D2)
)

Parameters

x D1

a _decimal value

y D2

a _decimal value

Return Value

Type: int

-1 if x precedes y, 0 if x is equal to y, +1 if x follows y Notes: The total order is defined as:<br/> - -sNaN < -NaN < -infinity < -finite < -0.0 < +0.0 < +finite < +infinity < +NaN < +sNaN<br/> - for two NaN values the total order is defined based on the payload

Examples

assert (cmp(-decimal32.nan, decimal64.max) == -1);
assert (cmp(decimal32.max, decimal128.min_normal) == 1);
assert (cmp(decimal64(0), -decimal64(0)) == 1);

Meta