Class java.math.BigInteger
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.math.BigInteger

java.lang.Object
   |
   +----java.lang.Number
           |
           +----java.math.BigInteger

public class BigInteger
extends Number
This version of BigInteger is just a wrapper class for long and its purpose is to only to support a JDK 1.0.2 version of BigDecimal.
See Also:
BigDecimal

Constructor Index

 o BigInteger(String)
Translates a string containing an optional minus sign followed by a sequence of one or more decimal digits into a BigInteger.
 o BigInteger(String, int)
Translates a string containing an optional minus sign followed by a sequence of one or more digits in the specified radix into a BigInteger.

Method Index

 o abs()
Returns a BigInteger whose value is the absolute value of this number.
 o add(BigInteger)
Returns a BigInteger whose value is (this + val).
 o compareTo(BigInteger)
Returns -1, 0 or 1 as this number is less than, equal to, or greater than val.
 o divide(BigInteger)
Returns a BigInteger whose value is (this / val).
 o divideAndRemainder(BigInteger)
Returns an array of two BigIntegers.
 o doubleValue()
Converts the number to a double.
 o equals(Object)
Returns true iff x is a BigInteger whose value is equal to this number.
 o floatValue()
Converts this number to a float.
 o hashCode()
Computes a hash code for this object.
 o intValue()
Converts this number to an int.
 o longValue()
Converts this number to a long.
 o max(BigInteger)
Returns the BigInteger whose value is the greater of this and val.
 o min(BigInteger)
Returns the BigInteger whose value is the lesser of this and val.
 o multiply(BigInteger)
Returns a BigInteger whose value is (this * val).
 o negate()
Returns a BigInteger whose value is (-1 * this).
 o pow(int)
Returns a BigInteger whose value is (this ** exponent).
 o remainder(BigInteger)
Returns a BigInteger whose value is (this % val).
 o signum()
Returns the signum function of this number (i.e., -1, 0 or 1 as the value of this number is negative, zero or positive).
 o subtract(BigInteger)
Returns a BigInteger whose value is (this - val).
 o testBit(int)
Returns true iff the designated bit is set.
 o toString()
Returns the string representation of this number, radix 10.
 o toString(int)
Returns the string representation of this number in the given radix.
 o valueOf(long)
Returns a BigInteger with the specified value.

Constructors

 o BigInteger
  public BigInteger(String val,
                    int radix) throws NumberFormatException
Translates a string containing an optional minus sign followed by a sequence of one or more digits in the specified radix into a BigInteger. The character-to-digit mapping is provided by Character.digit. Any extraneous characters (including whitespace), or a radix outside the range from Character.MIN_RADIX(2) to Character.MAX_RADIX(36), inclusive, will result in a NumberFormatException.
 o BigInteger
  public BigInteger(String val) throws NumberFormatException
Translates a string containing an optional minus sign followed by a sequence of one or more decimal digits into a BigInteger. The character-to-digit mapping is provided by Character.digit. Any extraneous characters (including whitespace) will result in a NumberFormatException.

Methods

 o valueOf
  public static BigInteger valueOf(long val)
Returns a BigInteger with the specified value. This factory is provided in preference to a (long) constructor because it allows for reuse of frequently used BigIntegers (like 0 and 1), obviating the need for exported constants.
 o add
  public BigInteger add(BigInteger val) throws ArithmeticException
Returns a BigInteger whose value is (this + val).
 o subtract
  public BigInteger subtract(BigInteger val)
Returns a BigInteger whose value is (this - val).
 o multiply
  public BigInteger multiply(BigInteger val) throws ArithmeticException
Returns a BigInteger whose value is (this * val).
 o divide
  public BigInteger divide(BigInteger val) throws ArithmeticException
Returns a BigInteger whose value is (this / val). Throws an ArithmeticException if val == 0.
 o remainder
  public BigInteger remainder(BigInteger val) throws ArithmeticException
Returns a BigInteger whose value is (this % val). Throws an ArithmeticException if val == 0.
 o divideAndRemainder
  public BigInteger[] divideAndRemainder(BigInteger val) throws ArithmeticException
Returns an array of two BigIntegers. The first ([0]) element of the return value is the quotient (this / val), and the second ([1]) element is the remainder (this % val). Throws an ArithmeticException if val == 0.
 o testBit
  public boolean testBit(int n) throws ArithmeticException
Returns true iff the designated bit is set. (Computes ((this & (1<  o pow
  public BigInteger pow(int exponent) throws ArithmeticException
Returns a BigInteger whose value is (this ** exponent). Throws an ArithmeticException if exponent < 0 (as the operation would yield a non-integer value). Note that exponent is an integer rather than a BigInteger.
 o abs
  public BigInteger abs()
Returns a BigInteger whose value is the absolute value of this number.
 o negate
  public BigInteger negate()
Returns a BigInteger whose value is (-1 * this).
 o signum
  public int signum()
Returns the signum function of this number (i.e., -1, 0 or 1 as the value of this number is negative, zero or positive).
 o compareTo
  public int compareTo(BigInteger val)
Returns -1, 0 or 1 as this number is less than, equal to, or greater than val. This method is provided in preference to individual methods for each of the six boolean comparison operators (<, ==, >, >=, !=, <=). The suggested idiom for performing these comparisons is: (x.compareTo(y) 0), where is one of the six comparison operators.
 o equals
  public boolean equals(Object x)
Returns true iff x is a BigInteger whose value is equal to this number. This method is provided so that BigIntegers can be used as hash keys.
Overrides:
equals in class Object
 o min
  public BigInteger min(BigInteger val)
Returns the BigInteger whose value is the lesser of this and val. If the values are equal, either may be returned.
 o max
  public BigInteger max(BigInteger val)
Returns the BigInteger whose value is the greater of this and val. If the values are equal, either may be returned.
 o hashCode
  public int hashCode()
Computes a hash code for this object.
Overrides:
hashCode in class Object
 o toString
  public String toString(int radix)
Returns the string representation of this number in the given radix. If the radix is outside the range from Character.MIN_RADIX(2) to Character.MAX_RADIX(36) inclusive, it will default to 10 (as is the case for Integer.toString). The digit-to-character mapping provided by Character.forDigit is used, and a minus sign is prepended if appropriate. (This representation is compatible with the (String, int) constructor.)
 o toString
  public String toString()
Returns the string representation of this number, radix 10. The digit-to-character mapping provided by Character.forDigit is used, and a minus sign is prepended if appropriate. (This representation is compatible with the (String) constructor, and allows for string concatenation with Java's + operator.)
Overrides:
toString in class Object
 o intValue
  public int intValue()
Converts this number to an int. Standard narrowing primitive conversion as per The Java Language Specification.
Overrides:
intValue in class Number
 o longValue
  public long longValue()
Converts this number to a long. Standard narrowing primitive conversion as per The Java Language Specification.
Overrides:
longValue in class Number
 o floatValue
  public float floatValue()
Converts this number to a float. Similar to the double-to-float narrowing primitive conversion defined in The Java Language Specification: if the number has too great a magnitude to represent as a float, it will be converted to infinity or negative infinity, as appropriate.
Overrides:
floatValue in class Number
 o doubleValue
  public double doubleValue()
Converts the number to a double. Similar to the double-to-float narrowing primitive conversion defined in The Java Language Specification: if the number has too great a magnitude to represent as a double, it will be converted to infinity or negative infinity, as appropriate.
Overrides:
doubleValue in class Number

All Packages  Class Hierarchy  This Package  Previous  Next  Index