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)); }
std.algorithm.comparison.max is faster because it does not perform the isNaN test.
Returns the larger of x and y.
If one of the arguments is a NaN, the other is returned.