-/*
-* The steps for construction of a BigInteger
-* from an integral value x are as follows:
-* 1. If x is zero, create an empty BigInteger and stop.
-* 2. Allocate a one-block number array.
-* 3. If x is positive (or of an unsigned type), set the
-* sign of the BigInteger to positive.
-* 4. If x is of a signed type and is negative, set the
-* sign of the BigInteger to negative.
-* 5. If x is of a signed type, convert x (or -x if x < 0)
-* to the unsigned type of the same length.
-* 6. Expand x (or the result of step 5) to a Blk,
-* and store it in the number array.
-*
-* See remarks in `BigUnsigned.cc' and `NumberlikeArray.hh'
-* about new handling of zero-length arrays.
-*/
-
-BigInteger::BigInteger(unsigned long x) {
- if (x == 0)
- sign = zero; // NumberlikeArray did the rest
- else {
- cap = 1;
- blk = new Blk[1];
- sign = positive;
- len = 1;
- blk[0] = Blk(x);
- }
-}
-
-BigInteger::BigInteger(long x) {
- if (x > 0) {
- cap = 1;
- blk = new Blk[1];
- sign = positive;
- len = 1;
- blk[0] = Blk(x);
- } else if (x < 0) {
- cap = 1;
- blk = new Blk[1];
- sign = negative;
- len = 1;
- blk[0] = Blk(-x);
- } else
- sign = zero;
-}
-
-BigInteger::BigInteger(unsigned int x) {
- if (x == 0)
+BigInteger::BigInteger(const BigUnsigned &x, Sign s) : mag(x) {
+ switch (s) {
+ case zero:
+ if (!mag.isZero())
+ throw "BigInteger::BigInteger(const BigUnsigned &, Sign): Cannot use a sign of zero with a nonzero magnitude";