The absolute value of the number. If floating-point or integral, the return type will be the same as the input.
Limitations: When x is a signed integral equal to Num.min the value of x will be returned instead. Note for 2's complement; -Num.min (= Num.max + 1) is not representable due to overflow.
import std.math.traits : isIdentical, isNaN; assert(isIdentical(abs(-0.0L), 0.0L)); assert(isNaN(abs(real.nan))); assert(abs(-real.infinity) == real.infinity); assert(abs(-56) == 56); assert(abs(2321312L) == 2321312L); assert(abs(23u) == 23u);
Calculates the absolute value of a number.