FileDocCategorySizeDatePackage
SignedMutableBigInteger.javaAPI DocJava SE 6 API3094Tue Jun 10 00:25:40 BST 2008java.math

SignedMutableBigInteger

public class SignedMutableBigInteger extends MutableBigInteger
A class used to represent multiprecision integers that makes efficient use of allocated space by allowing a number to occupy only part of an array so that the arrays do not have to be reallocated as often. When performing an operation with many iterations the array used to hold a number is only increased when necessary and does not have to be the same size as the number it represents. A mutable number allows calculations to occur on the same number without having to create a new number for every step of the calculation as occurs with BigIntegers. Note that SignedMutableBigIntegers only support signed addition and subtraction. All other operations occur as with MutableBigIntegers.
see
BigInteger
version
1.10, 11/17/05
author
Michael McCloskey
since
1.3

Fields Summary
int
sign
The sign of this MutableBigInteger.
Constructors Summary
SignedMutableBigInteger()
The default constructor. An empty MutableBigInteger is created with a one word capacity.


    // Constructors

                      
     
        super();
    
SignedMutableBigInteger(int val)
Construct a new MutableBigInteger with a magnitude specified by the int val.

        super(val);
    
SignedMutableBigInteger(MutableBigInteger val)
Construct a new MutableBigInteger with a magnitude equal to the specified MutableBigInteger.

        super(val);
    
Methods Summary
voidsignedAdd(java.math.SignedMutableBigInteger addend)
Signed addition built upon unsigned add and subtract.

        if (sign == addend.sign)
            add(addend);
        else
            sign = sign * subtract(addend);

    
voidsignedAdd(java.math.MutableBigInteger addend)
Signed addition built upon unsigned add and subtract.

        if (sign == 1)
            add(addend);
        else
            sign = sign * subtract(addend);
        
    
voidsignedSubtract(java.math.SignedMutableBigInteger addend)
Signed subtraction built upon unsigned add and subtract.

        if (sign == addend.sign)
            sign = sign * subtract(addend);
        else
            add(addend);
        
    
voidsignedSubtract(java.math.MutableBigInteger addend)
Signed subtraction built upon unsigned add and subtract.

        if (sign == 1)
            sign = sign * subtract(addend);
        else
            add(addend);
        if (intLen == 0)
             sign = 1;
    
public java.lang.StringtoString()
Print out the first intLen ints of this MutableBigInteger's value array starting at offset.

        BigInteger b = new BigInteger(this, sign);
        return
            b.toString();