mostNegative

Returns the most negative value of the numeric type T.

template mostNegative (
T
) if (
isNumeric!T ||
isSomeChar!T
||
isBoolean!T
) {
static if(is(typeof(T.min_normal)))
enum mostNegative;
static if(!(is(typeof(T.min_normal))))
static if(T.min == 0)
enum byte mostNegative;
static if(!(is(typeof(T.min_normal))))
static if(!(T.min == 0))
enum mostNegative;
}

Examples

static assert(mostNegative!float == -float.max);
static assert(mostNegative!double == -double.max);
static assert(mostNegative!real == -real.max);
static assert(mostNegative!bool == false);
import std.meta : AliasSeq;

static foreach (T; AliasSeq!(bool, byte, short, int, long))
    static assert(mostNegative!T == T.min);

static foreach (T; AliasSeq!(ubyte, ushort, uint, ulong, char, wchar, dchar))
    static assert(mostNegative!T == 0);

Meta