|
Generated by JDiff |
||||||||
PREV PACKAGE NEXT PACKAGE FRAMES NO FRAMES |
This file contains all the changes in documentation in the packagejava.math
as colored differences. Deletions are shownlike this, and additions are shown like this.
If no deletions or additions are shown in an entry, the HTML tags will be what has changed. The new HTML tags are shown in the differences. If no documentation existed, and then some was added in a later version, this change is noted in the appropriate class pages of differences, but the change is not shown on this page. Only changes in existing text are shown here. Similarly, documentation which was inherited from another class or interface is not shown here.
Note that an HTML error in the new documentation may cause the display of other documentation changes to be presented incorrectly. For instance, failure to close a <code> tag will cause all subsequent paragraphs to be displayed differently.
Immutable arbitrary-precision signed decimal numbers. A BigDecimal consists of an arbitrary precision integer unscaled value and a non-negative 32-bit integer scale which represents the number of digits to the right of the decimal point. The number represented by the BigDecimal is (unscaledValue/10scale). BigDecimal provides operations for basic arithmetic scale manipulation comparison hashing and format conversion.Class BigDecimal, constructor BigDecimal(String)The BigDecimal class gives its user complete control over rounding behavior forcing the user to explicitly specify a rounding behavior for operations capable of discarding precision ({@link #divide(BigDecimal
andint)}setScalein int).}Eightand Eigh rounding modes are provided for this purpose.Two types of operations are provided for manipulating the scale of a BigDecimal: scaling/rounding operations and decimal point motion operations. Scaling/rounding operations (
SetScalesetScale) return a BigDecimal whose value is approximately (or exactly) equal to that of the operand but whose scale is the specified value; that is they increase or decrease the precision of the number with minimal effect on its value. Decimal point motion operations ({@link #movePointLeft} andmovePointRight) returnretur a BigDecimal created from the operand by moving the decimal point a specified distance in the specified direction; that is they change a number's value without affecting its precision.For the sake of brevity and clarity pseudo-code is used throughout the descriptions of BigDecimal methods. The pseudo-code expression (i + j) is shorthand for "a BigDecimal whose value is that of the BigDecimal i plus that of the BigDecimal j." The pseudo-code expression (i == j) is shorthand for "true if and only if the BigDecimal i represents the same value as the the BigDecimal j." Other pseudo-code expressions are interpreted similarly.
Note: care should be exercised if BigDecimals are to be used as keys in a java.util.SortedMap or elements in a java.util.SortedSet as BigDecimal's natural ordering is inconsistent with equals. See Comparable java.util.SortedMap or java.util.SortedSet for more information.
All methods and constructors for this class throw
NullPointerException
when passed a null object reference for any input parameter. @see BigInteger @see java.util.SortedMap @see java.util.SortedSet @version 1.29 0236 09/0221/0001 @author Josh Bloch
Translates the String representation of aClass BigDecimal, int compareTo(Object)BigDecmalBigDecimal into a BigDecimal. The String representation consists of an optional sign('+' ('\u002B') or '-' ('\u002D') followed by a sequence of zero or more decimal digits ("the integer") optionally followed by a fraction optionally followed by an exponent.The fraction consists of of a decimal point followed by zero or more decimal digits. The string must contain at least one digit in either the integer or the fraction. The number formed by the sign the integer and the fraction is referred to as the significand.
The exponent consists of the character 'e' (
0x75'\u0075') or 'E' (0x45'\u0045') followed by one or more decimal digits. The value of theexponenetexponent must lie between -{@link Integer.#MAX_VALUE} ({@link Integer#MIN_VALUE}+1) and Integer.MAX_VALUE inclusive.More formally the strings this constructor accepts are described by the following grammar:
The scale of the returned BigDecimal will be the number of digits in the fraction or zero if the string contains no decimal point subject to adjustment for any exponent: If the string contains an exponent the exponent is subtracted from the scale. If the resulting scale is negative the scale of the returned BigDecimal is zero and the unscaled value is multiplied by the appropriate power of ten so that in every case the resulting BigDecimal is equal to significand
- BigDecimalString:
- Signopt Significand Exponentopt
- Sign:
+
-
- Significand:
- IntegerPart
.
FractionPartopt.
FractionPart- IntegerPart
- IntegerPart:
- Digits
- FractionPart:
- Digits
- Exponent:
- ExponentIndicator SignedInteger
- ExponentIndicator:
e
E
- SignedInteger:
- Signopt Digits
- Digits:
- Digit
- Digits Digit
- Digit:
- any character for which Character#isDigit returns
true
including 0 1 2 ...*× 10exponent. (If in the future this specification is amended to permit negative scales the final step of zeroing the scale and adjusting the unscaled value will be eliminated.)The character-to-digit mapping is provided by java.lang.Character#digit set to convert to radix 10. The String may not contain any extraneous characters (whitespace for example).
Note: For
floats (and doubles)values otherthatfloatNANand+INFINITYdouble NaN and-INFINITY±Infinity this constructor is compatible with the values returned by Float.#toString(and Double.#toString).This is generally the preferred way to convert a float(or double)into a BigDecimal as it doesn't suffer from the unpredictability of the #BigDecimal(double) constructor.Note: the optional leading plus sign and trailing exponent were added in release 1.3. @param val String representation of BigDecimal. @throws NumberFormatException val is not a valid representation of a BigDecimal.
Compares this BigDecimal with the specified Object. If the Object is a BigDecimal this method behaves like #compareToClass BigDecimal, double doubleValue()(BigDecimal).Otherwise it throws a ClassCastException (as BigDecimals are comparable only to other BigDecimals). @param o Object to which this BigDecimal is to be compared. @return a negative number zero or a positive number as this BigDecimal is numerically less than equal to or greater than o which must be a BigDecimal. @throws ClassCastException o is not a BigDecimal. @see #compareTo(java.math.BigDecimal) @see Comparable @since 1.2
Converts this BigDecimal to a double. Similar to the double-to-float narrowing primitive conversion defined in The Java Language Specification: if this BigDecimal has too great a magnitude to represent as a double it will be converted toClass BigDecimal, boolean equals(Object)DOUBLEDouble.NEGATIVE_INFINITY orDOUBLEDouble.POSITIVE_INFINITY as appropriate. @return this BigDecimal converted to a double.
Compares this BigDecimal with the specified Object for equality. Unlike #compareTo this method considers two BigDecimals equal only if they are equal in value and scale (thus 2.0 is not equal to 2.00 when compared by this method). @param x Object to which this BigDecimal is to be compared. @return true if and only if the specified Object is a BigDecimal whose value and scale are equal to this BigDecimal's. @see #compareTo(java.math.BigDecimal)Class BigDecimal, float floatValue()
Converts this BigDecimal to a float. Similar to the double-to-float narrowing primitive conversion defined in The Java Language Specification: if this BigDecimal has too great a magnitude to represent as a float it will be converted toClass BigDecimal, int intValue()FLOATFloat.NEGATIVE_INFINITY orFLOATFloat.POSITIVE_INFINITY as appropriate. @return this BigDecimal converted to a float.
Converts this BigDecimal to an int.Class BigDecimal, long longValue()StandardThis is standard narrowing primitive conversion as defined in The Java Language Specification: any fractional part of this BigDecimal will be discarded and if the resulting "BigInteger" is too big to fit in an int only the low-order 32 bits are returned. @return this BigDecimal converted to an int.
Converts this BigDecimal to a long.Class BigDecimal, BigDecimal max(BigDecimal)StandardThis is standard narrowing primitive conversion as defined in The Java Language Specification: any fractional part of this BigDecimal will be discarded and if the resulting "BigInteger" is too big to fit in a long only the low-order 64 bits are returned. @return this BigDecimal converted to an int.
Returns the maximum of this BigDecimal and val. @param val value with with the maximum is to be computed. @return the BigDecimal whose value is the greater of this BigDecimal and val. If they are equal as defined by the #compareTo method either may be returned. @see #compareTo(java.math.BigDecimal)Class BigDecimal, BigDecimal min(BigDecimal)
Returns the minimum of this BigDecimal and val. @param val value with with the minimum is to be computed. @return the BigDecimal whose value is the lesser of this BigDecimal and val. If they are equal as defined by the #compareTo method either may be returned. @see #compareTo(java.math.BigDecimal)Class BigDecimal, BigDecimal negate()
Returns a BigDecimal whose value is (-this) and whose scale is this.scale(). @return -thisClass BigDecimal, String toString()
Returns the string representation of this BigDecimal. The digit-to- character mapping provided by Character.#forDigit is used. A leading minus sign is used to indicate sign and the number of digits to the right of the decimal point is used to indicate scale. (This representation is compatible with the (String) constructor.) @return String representation of this BigDecimal. @see Character#forDigit @see #BigDecimal(java.lang.String)
Immutable arbitrary-precision integers. All operations behave as if BigIntegers were represented in two's-complement notation (like Java's primitive integer types). BigInteger provides analogues to all of Java's primitive integer operators and all relevant methods from java.lang.Math. Additionally BigInteger provides operations for modular arithmetic GCD calculation primality testing prime generation bit manipulation and a few other miscellaneous operations.Class BigInteger, int intValue()Semantics of arithmetic operations exactly mimic those of Java's integer arithmetic operators as defined in The Java Language Specification. For example division by zero throws an ArithmeticException and division of a negative by a positive yields a negative (or zero) remainder. All of the details in the Spec concerning overflow are ignored as BigIntegers are made as large as necessary to accommodate the results of an operation.
Semantics of shift operations extend those of Java's shift operators to allow for negative shift distances. A right-shift with a negative shift distance results in a left shift and vice-versa. The unsigned right shift operator (>>>) is omitted as this operation makes little sense in combination with the "infinite word size" abstraction provided by this class.
Semantics of bitwise logical operations exactly mimic those of Java's bitwise integer operators. The binary operators (and or xor) implicitly perform sign extension on the shorter of the two operands prior to performing the operation.
Comparison operations perform signed integer comparisons analogous to those performed by Java's relational and equality operators.
Modular arithmetic operations are provided to compute residues perform exponentiation and compute multiplicative inverses. These methods always return a non-negative result between 0 and (modulus - 1) inclusive.
Bit operations operate on a single bit of the two's-complement representation of their operand. If necessary the operand is sign- extended so that it contains the designated bit. None of the single-bit operations can produce a BigInteger with a different sign from the BigInteger being operated on as they affect only a single bit and the "infinite word size" abstraction provided by this class ensures that there are infinitely many "virtual sign bits" preceding each BigInteger.
For the sake of brevity and clarity pseudo-code is used throughout the descriptions of BigInteger methods. The pseudo-code expression (i + j) is shorthand for "a BigInteger whose value is that of the BigInteger i plus that of the BigInteger j." The pseudo-code expression (i == j) is shorthand for "true if and only if the BigInteger i represents the same value as the the BigInteger j." Other pseudo-code expressions are interpreted similarly.
All methods and constructors in this class throw
NullPointerException
when passed a null object reference for any input parameter. @see BigDecimal @version 1.43 0249 09/1612/01 @author Josh Bloch @author Michael McCloskey @since JDK1.1
Converts this BigInteger to an int.Class BigInteger, long longValue()StandardThis is standard narrowing primitive conversion as defined in The Java Language Specification: if this BigInteger is too big to fit in an int only the low-order 32 bits are returned. @return this BigInteger converted to an int.
Converts this BigInteger to a long.StandardThis is standard narrowing primitive conversion as defined in The Java Language Specification: if this BigInteger is too big to fit in a long only the low-order 64 bits are returned. @return this BigInteger converted to a long.