X-Git-Url: https://mattmccutchen.net/bigint/bigint.git/blobdiff_plain/3e1327901d299a537a8d932c49dd330f87ac3bda..a305e8a577403b7c952e3900f64bbacf464edd98:/BigInteger.cc diff --git a/BigInteger.cc b/BigInteger.cc index 2651ab7..56f30ab 100644 --- a/BigInteger.cc +++ b/BigInteger.cc @@ -39,15 +39,9 @@ BigInteger::BigInteger(const BigUnsigned &x, Sign s) : mag(x) { * negative BigInteger instead of an exception. */ // Done longhand to let us use initialization. -BigInteger::BigInteger(unsigned long x) : mag(x) { - sign = mag.isZero() ? zero : positive; -} -BigInteger::BigInteger(unsigned int x) : mag(x) { - sign = mag.isZero() ? zero : positive; -} -BigInteger::BigInteger(unsigned short x) : mag(x) { - sign = mag.isZero() ? zero : positive; -} +BigInteger::BigInteger(unsigned long x) : mag(x) { sign = mag.isZero() ? zero : positive; } +BigInteger::BigInteger(unsigned int x) : mag(x) { sign = mag.isZero() ? zero : positive; } +BigInteger::BigInteger(unsigned short x) : mag(x) { sign = mag.isZero() ? zero : positive; } // For signed input, determine the desired magnitude and sign separately. @@ -66,12 +60,9 @@ namespace { } } -BigInteger::BigInteger(long x) : sign(signOf(x)), - mag(magOf(x)) {} -BigInteger::BigInteger(int x) : sign(signOf(x)), - mag(magOf(x)) {} -BigInteger::BigInteger(short x) : sign(signOf(x)), - mag(magOf(x)) {} +BigInteger::BigInteger(long x) : sign(signOf(x)), mag(magOf(x)) {} +BigInteger::BigInteger(int x) : sign(signOf(x)), mag(magOf(x)) {} +BigInteger::BigInteger(short x) : sign(signOf(x)), mag(magOf(x)) {} // CONVERSION TO PRIMITIVE INTEGERS @@ -119,24 +110,12 @@ X BigInteger::convertToSignedPrimitive() const { "Value is too big to fit in the requested type"; } -unsigned long BigInteger::toUnsignedLong() const { - return convertToUnsignedPrimitive(); -} -unsigned int BigInteger::toUnsignedInt() const { - return convertToUnsignedPrimitive(); -} -unsigned short BigInteger::toUnsignedShort() const { - return convertToUnsignedPrimitive(); -} -long BigInteger::toLong() const { - return convertToSignedPrimitive(); -} -int BigInteger::toInt() const { - return convertToSignedPrimitive(); -} -short BigInteger::toShort() const { - return convertToSignedPrimitive(); -} +unsigned long BigInteger::toUnsignedLong () const { return convertToUnsignedPrimitive (); } +unsigned int BigInteger::toUnsignedInt () const { return convertToUnsignedPrimitive (); } +unsigned short BigInteger::toUnsignedShort() const { return convertToUnsignedPrimitive (); } +long BigInteger::toLong () const { return convertToSignedPrimitive (); } +int BigInteger::toInt () const { return convertToSignedPrimitive (); } +short BigInteger::toShort () const { return convertToSignedPrimitive (); } // COMPARISON BigInteger::CmpRes BigInteger::compareTo(const BigInteger &x) const {