Change private function BigInt.isNegative to an alias

This commit is contained in:
Nathan Sashihara 2020-11-25 20:26:35 -08:00 committed by The Dlang Bot
parent fe60735735
commit b09ef4c1ae

View file

@ -1286,7 +1286,7 @@ public:
} }
assert(buff.length > 0, "Invalid buffer length"); assert(buff.length > 0, "Invalid buffer length");
char signChar = isNegative() ? '-' : 0; char signChar = isNegative ? '-' : 0;
auto minw = buff.length + (signChar ? 1 : 0); auto minw = buff.length + (signChar ? 1 : 0);
if (!hex && !signChar && (f.width == 0 || minw < f.width)) if (!hex && !signChar && (f.width == 0 || minw < f.width))
@ -1459,10 +1459,7 @@ private:
{ {
return data.isZero(); return data.isZero();
} }
bool isNegative() pure const nothrow @nogc @safe alias isNegative = sign;
{
return sign;
}
// Generate a runtime error if division by zero occurs // Generate a runtime error if division by zero occurs
void checkDivByZero() pure const nothrow @safe void checkDivByZero() pure const nothrow @safe
@ -2160,23 +2157,23 @@ unittest
{ {
auto x = BigInt(-3); auto x = BigInt(-3);
x %= 3; x %= 3;
assert(!x.isNegative()); assert(!x.isNegative);
assert(x.isZero()); assert(x.isZero);
x = BigInt(-3); x = BigInt(-3);
x %= cast(ushort) 3; x %= cast(ushort) 3;
assert(!x.isNegative()); assert(!x.isNegative);
assert(x.isZero()); assert(x.isZero);
x = BigInt(-3); x = BigInt(-3);
x %= 3L; x %= 3L;
assert(!x.isNegative()); assert(!x.isNegative);
assert(x.isZero()); assert(x.isZero);
x = BigInt(3); x = BigInt(3);
x %= -3; x %= -3;
assert(!x.isNegative()); assert(!x.isNegative);
assert(x.isZero()); assert(x.isZero);
} }
// https://issues.dlang.org/show_bug.cgi?id=15678 // https://issues.dlang.org/show_bug.cgi?id=15678