cmp

fnint cmp(T)(const(T) x, const(T) y) if (isFloatingPoint!T) @nogc @trusted pure nothrow

Defines a total order on all floating-point numbers.

The order is defined as follows:

  • All numbers in [-∞, +∞] are ordered

    the same way as by built-in comparison, with the exception of -0.0, which is less than +0.0;

  • If the sign bit is set (that is, it's 'negative'), NaN is less

    than any number; if the sign bit is not set (it is 'positive'), NaN is greater than any number;

  • NaNs of the same sign are ordered by the payload ('negative'

    ones - in reverse order).

Returns

negative value if x precedes y in the order specified above;

0 if x and y are identical, and positive value otherwise.

See Also

Standards

Conforms to IEEE 754-2008