negative value if x precedes y in the order specified above; 0 if x and y are identical, and positive value otherwise.
Most numbers are ordered naturally.
assert(cmp(-double.infinity, -double.max) < 0); assert(cmp(-double.max, -100.0) < 0); assert(cmp(-100.0, -0.5) < 0); assert(cmp(-0.5, 0.0) < 0); assert(cmp(0.0, 0.5) < 0); assert(cmp(0.5, 100.0) < 0); assert(cmp(100.0, double.max) < 0); assert(cmp(double.max, double.infinity) < 0); assert(cmp(1.0, 1.0) == 0);
Positive and negative zeroes are distinct.
assert(cmp(-0.0, +0.0) < 0); assert(cmp(+0.0, -0.0) > 0);
Depending on the sign, NaNs go to either end of the spectrum.
assert(cmp(-double.nan, -double.infinity) < 0); assert(cmp(double.infinity, double.nan) < 0); assert(cmp(-double.nan, double.nan) < 0);
NaNs of the same sign are ordered by the payload.
assert(cmp(NaN(10), NaN(20)) < 0); version (LDC_Win32) { // somehow fails with LLVM 8.0 + disabled optimizations } else { assert(cmp(-NaN(20), -NaN(10)) < 0); }
Conforms to IEEE 754-2008
Defines a total order on all floating-point numbers.
The order is defined as follows: