Java Big Decimal Adapter
Properties
Returns a BigDecimal whose value is the absolute value of this BigDecimal, and whose _scale is this._scale().
Returns the _precision of this BigDecimal. (The _precision is the number of digits in the unscaled value.)
Returns the _scale of this BigDecimal. If zero or positive, the _scale is the number of digits to the right of the decimal point. If negative, the unscaled value of the number is multiplied by ten to the power of the negation of the _scale. For example, a _scale of -3 means the unscaled value is multiplied by 1000.
Returns the _signum function of this BigDecimal.
Returns a BigInteger whose value is the unscaled value of this BigDecimal. (Computes (this * 10<sup>this._scale()</sup>).)
Functions
Returns a BigDecimal whose value is the absolute value of this BigDecimal, with rounding according to the context settings.
Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in value but have a different _scale (like 2.0 and 2.00) are considered equal by this method. 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)<op>0), where <op> is one of the six comparison operators.
Returns a BigDecimal whose value is (this / divisor), and whose preferred _scale is (this._scale() - divisor._scale()); if the exact quotient cannot be represented (because it has a non-terminating decimal expansion) an ArithmeticException is thrown.
Returns a BigDecimal whose value is (this / divisor), with rounding according to the context settings.
Returns a two-element BigDecimal array containing the result of divideToIntegralValue followed by the result of remainder on the two operands.
Returns a two-element BigDecimal array containing the result of divideToIntegralValue followed by the result of remainder on the two operands calculated with rounding according to the context settings.
Returns a BigDecimal whose value is the integer part of the quotient (this / divisor) rounded down. The preferred _scale of the result is (this._scale() - divisor._scale()).
Returns a BigDecimal whose value is the integer part of (this / divisor). Since the integer part of the exact quotient does not depend on the rounding mode, the rounding mode does not affect the values returned by this method. The preferred _scale of the result is (this._scale() - divisor._scale()). An ArithmeticException is thrown if the integer part of the exact quotient needs more than mc._precision digits.
Returns the maximum of this BigDecimal and val.
Returns the minimum of this BigDecimal and val.
Returns a BigDecimal whose value is (this - subtrahend), and whose _scale is max(this._scale(), subtrahend._scale()).
Returns a BigDecimal whose value is (this - subtrahend), with rounding according to the context settings.
Returns a BigDecimal which is equivalent to this one with the decimal point moved n places to the left. If n is non-negative, the call merely adds n to the _scale. If n is negative, the call is equivalent to movePointRight(-n). The BigDecimal returned by this call has value (this 10<sup>-n</sup>) and _scale max(this._scale()+n, 0).
Returns a BigDecimal which is equivalent to this one with the decimal point moved n places to the right. If n is non-negative, the call merely subtracts n from the _scale. If n is negative, the call is equivalent to movePointLeft(-n). The BigDecimal returned by this call has value (this 10<sup>n</sup>) and _scale max(this._scale()-n, 0).
Returns a BigDecimal whose value is (this + augend), and whose _scale is max(this._scale(), augend._scale()).
Returns a BigDecimal whose value is (this + augend), with rounding according to the context settings.
Returns a BigDecimal whose value is (this<sup>n</sup>), The power is computed exactly, to unlimited _precision.
Returns a BigDecimal whose value is (this<sup>n</sup>). The current implementation uses the core algorithm defined in ANSI standard X3.274-1996 with rounding according to the context settings. In general, the returned numerical value is within two ulps of the exact numerical value for the chosen _precision. Note that future releases may use a different algorithm with a decreased allowable error bound and increased allowable exponent range.
Returns a BigDecimal whose value is (this % divisor).
Returns a BigDecimal whose value is (this % divisor), with rounding according to the context settings. The MathContext settings affect the implicit div used to compute the remainder. The remainder computation itself is by definition exact. Therefore, the remainder may contain more than mc.getPrecision() digits.
Returns a BigDecimal rounded according to the MathContext settings. If the _precision setting is 0 then no rounding takes place.
Returns a BigDecimal whose numerical value is equal to (this * 10n). The _scale of the result is (this._scale() - n).
Returns a BigDecimal whose _scale is the specified value, and whose value is numerically equal to this BigDecimal's. Throws an ArithmeticException if this is not possible.
Returns a BigDecimal whose _scale is the specified value, and whose unscaled value is determined by multiplying or dividing this BigDecimal's unscaled value by the appropriate power of ten to maintain its overall value. If the _scale is reduced by the operation, the unscaled value must be divided (rather than multiplied), and the value may be changed; in this case, the specified rounding mode is applied to the division.
Returns an approximation to the square root of this with rounding according to the context settings.
Returns a BigDecimal which is numerically equal to this one but with any trailing zeros removed from the representation. For example, stripping the trailing zeros from the BigDecimal value 600.0, which has [BigInteger, _scale] components equals to [6000, 1], yields 6E2 with [BigInteger, scale] components equals to [6, -2]. If this BigDecimal is numerically equal to zero, then BigDecimal.ZERO is returned.
Returns a BigDecimal whose value is (this multiplicand), and whose _scale is (this._scale() + multiplicand._scale()).
Returns a BigDecimal whose value is (this multiplicand), with rounding according to the context settings.
Converts this BigDecimal to a BigInteger. This conversion is analogous to the narrowing primitive conversion from double to long as defined in The Java Language Specification: any fractional part of this BigDecimal will be discarded. Note that this conversion can lose information about the _precision of the BigDecimal value.
Converts this BigDecimal to a BigInteger, checking for lost information. An exception is thrown if this BigDecimal has a nonzero fractional part.
Converts this BigDecimal to a byte, checking for lost information. If this BigDecimal has a nonzero fractional part or is out of the possible range for a byte result then an ArithmeticException is thrown.
Converts this BigDecimal to a double. This conversion is similar to the narrowing primitive conversion from double to float as defined in The Java Language Specification: if this BigDecimal has too great a magnitude represent as a double, it will be converted to Double.NEGATIVE_INFINITY or as appropriate. Note that even when the return value is finite, this conversion can lose information about the _precision of the BigDecimal value.
Returns a string representation of this BigDecimal, using engineering notation if an exponent is needed.
Converts this BigDecimal to a float. This conversion is similar to the narrowing primitive conversion from double to float as defined in The Java Language Specification: if this BigDecimal has too great a magnitude to represent as a float, it will be converted to Float.NEGATIVE_INFINITY or as appropriate. Note that even when the return value is finite, this conversion can lose information about the _precision of the BigDecimal value.
Converts this BigDecimal to an int. This conversion is analogous to the narrowing primitive conversion from double to short 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. Note that this conversion can lose information about the overall magnitude and _precision of this BigDecimal value as well as return a result with the opposite sign.
Converts this BigDecimal to an int, checking for lost information. If this BigDecimal has a nonzero fractional part or is out of the possible range for an int result then an ArithmeticException is thrown.
Converts this BigDecimal to a long. This conversion is analogous to the narrowing primitive conversion from double to short 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. Note that this conversion can lose information about the overall magnitude and _precision of this BigDecimal value as well as return a result with the opposite sign.
Converts this BigDecimal to a long, checking for lost information. If this BigDecimal has a nonzero fractional part or is out of the possible range for a long result then an ArithmeticException is thrown.
Returns a string representation of this BigDecimal without an exponent field. For values with a positive _scale, the number of digits to the right of the decimal point is used to indicate _scale. For values with a zero or negative _scale, the resulting string is generated as if the value were converted to a numerically equal value with zero _scale and as if all the trailing zeros of the zero _scale value were present in the result.
Converts this BigDecimal to a short, checking for lost information. If this BigDecimal has a nonzero fractional part or is out of the possible range for a short result then an ArithmeticException is thrown.
Returns the size of an ulp, a unit in the last place, of this BigDecimal. An ulp of a nonzero BigDecimal value is the positive distance between this value and the BigDecimal value next larger in magnitude with the same number of digits. An ulp of a zero value is numerically equal to 1 with the _scale of this. The result is stored with the same _scale as this so the result for zero and nonzero values is equal to [1, this._scale()].
Returns a BigDecimal whose value is (-this), and whose _scale is this._scale().
Returns a BigDecimal whose value is (-this), with rounding according to the context settings.
Returns a BigDecimal whose value is (+this), and whose _scale is this._scale().
Returns a BigDecimal whose value is (+this), with rounding according to the context settings.