* 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.
}
}
-BigInteger::BigInteger(long x) : sign(signOf(x)),
- mag(magOf<long, unsigned long>(x)) {}
-BigInteger::BigInteger(int x) : sign(signOf(x)),
- mag(magOf<int, unsigned int>(x)) {}
-BigInteger::BigInteger(short x) : sign(signOf(x)),
- mag(magOf<short, unsigned short>(x)) {}
+BigInteger::BigInteger(long x) : sign(signOf(x)), mag(magOf<long , unsigned long >(x)) {}
+BigInteger::BigInteger(int x) : sign(signOf(x)), mag(magOf<int , unsigned int >(x)) {}
+BigInteger::BigInteger(short x) : sign(signOf(x)), mag(magOf<short, unsigned short>(x)) {}
// CONVERSION TO PRIMITIVE INTEGERS
"Value is too big to fit in the requested type";
}
-unsigned long BigInteger::toUnsignedLong() const {
- return convertToUnsignedPrimitive<unsigned long>();
-}
-unsigned int BigInteger::toUnsignedInt() const {
- return convertToUnsignedPrimitive<unsigned int>();
-}
-unsigned short BigInteger::toUnsignedShort() const {
- return convertToUnsignedPrimitive<unsigned short>();
-}
-long BigInteger::toLong() const {
- return convertToSignedPrimitive<long, unsigned long>();
-}
-int BigInteger::toInt() const {
- return convertToSignedPrimitive<int, unsigned int>();
-}
-short BigInteger::toShort() const {
- return convertToSignedPrimitive<short, unsigned short>();
-}
+unsigned long BigInteger::toUnsignedLong () const { return convertToUnsignedPrimitive<unsigned long > (); }
+unsigned int BigInteger::toUnsignedInt () const { return convertToUnsignedPrimitive<unsigned int > (); }
+unsigned short BigInteger::toUnsignedShort() const { return convertToUnsignedPrimitive<unsigned short> (); }
+long BigInteger::toLong () const { return convertToSignedPrimitive <long , unsigned long> (); }
+int BigInteger::toInt () const { return convertToSignedPrimitive <int , unsigned int> (); }
+short BigInteger::toShort () const { return convertToSignedPrimitive <short, unsigned short>(); }
// COMPARISON
BigInteger::CmpRes BigInteger::compareTo(const BigInteger &x) const {