fmax

Returns the larger of x and y.

If one of the arguments is a NaN, the other is returned.

@safe pure nothrow @nogc
F
fmax
(
F
)
(
const F x
,
const F y
)
if (
__traits(isFloating, F)
)

Examples

import std.meta : AliasSeq;
static foreach (F; AliasSeq!(float, double, real))
{
    assert(fmax(F(0.0), F(2.0)) == 2.0);
    assert(fmax(F(-2.0), 0.0) == F(0.0));
    assert(fmax(F.infinity, F(2.0)) == F.infinity);
    assert(fmax(F.nan, F(2.0)) == F(2.0));
    assert(fmax(F(2.0), F.nan) == F(2.0));
}

See Also

std.algorithm.comparison.max is faster because it does not perform the isNaN test.

Meta