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
-
BigInteger(String)
- Translates a string containing an optional minus sign followed by a
sequence of one or more decimal digits into a BigInteger.
-
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.
-
abs()
- Returns a BigInteger whose value is the absolute value of this
number.
-
add(BigInteger)
- Returns a BigInteger whose value is (this + val).
-
compareTo(BigInteger)
- Returns -1, 0 or 1 as this number is less than, equal to, or
greater than val.
-
divide(BigInteger)
- Returns a BigInteger whose value is (this / val).
-
divideAndRemainder(BigInteger)
- Returns an array of two BigIntegers.
-
doubleValue()
- Converts the number to a double.
-
equals(Object)
- Returns true iff x is a BigInteger whose value is equal to this number.
-
floatValue()
- Converts this number to a float.
-
hashCode()
- Computes a hash code for this object.
-
intValue()
- Converts this number to an int.
-
longValue()
- Converts this number to a long.
-
max(BigInteger)
- Returns the BigInteger whose value is the greater of this and val.
-
min(BigInteger)
- Returns the BigInteger whose value is the lesser of this and val.
-
multiply(BigInteger)
- Returns a BigInteger whose value is (this * val).
-
negate()
- Returns a BigInteger whose value is (-1 * this).
-
pow(int)
- Returns a BigInteger whose value is (this ** exponent).
-
remainder(BigInteger)
- Returns a BigInteger whose value is (this % val).
-
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).
-
subtract(BigInteger)
- Returns a BigInteger whose value is (this - val).
-
testBit(int)
- Returns true iff the designated bit is set.
-
toString()
- Returns the string representation of this number, radix 10.
-
toString(int)
- Returns the string representation of this number in the given radix.
-
valueOf(long)
- Returns a BigInteger with the specified value.
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.
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.
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.
add
public BigInteger add(BigInteger val) throws ArithmeticException
- Returns a BigInteger whose value is (this + val).
subtract
public BigInteger subtract(BigInteger val)
- Returns a BigInteger whose value is (this - val).
multiply
public BigInteger multiply(BigInteger val) throws ArithmeticException
- Returns a BigInteger whose value is (this * val).
divide
public BigInteger divide(BigInteger val) throws ArithmeticException
- Returns a BigInteger whose value is (this / val). Throws an
ArithmeticException if val == 0.
remainder
public BigInteger remainder(BigInteger val) throws ArithmeticException
- Returns a BigInteger whose value is (this % val). Throws an
ArithmeticException if val == 0.
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.
testBit
public boolean testBit(int n) throws ArithmeticException
- Returns true iff the designated bit is set. (Computes
((this & (1<
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.
abs
public BigInteger abs()
- Returns a BigInteger whose value is the absolute value of this
number.
negate
public BigInteger negate()
- Returns a BigInteger whose value is (-1 * this).
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).
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.
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
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.
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.
hashCode
public int hashCode()
- Computes a hash code for this object.
- Overrides:
- hashCode in class Object
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.)
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
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
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
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
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