JavaBigDecimalAdapter

Constructors

Link copied to clipboard
constructor(value: BigDecimal)

Properties

Link copied to clipboard
open override val absoluteValue: BigDecimal

Returns a BigDecimal whose value is the absolute value of this BigDecimal, and whose _scale is this._scale().

Link copied to clipboard
open override val precision: Int

Returns the _precision of this BigDecimal. (The _precision is the number of digits in the unscaled value.)

Link copied to clipboard
open override val scale: Int

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.

Link copied to clipboard
open override val signum: Int

Returns the _signum function of this BigDecimal.

Link copied to clipboard
open override val unscaledValue: BigInteger

Returns a BigInteger whose value is the unscaled value of this BigDecimal. (Computes (this * 10<sup>this._scale()</sup>).)

Link copied to clipboard

Functions

Link copied to clipboard
open override fun absoluteValue(mc: MathContext): BigDecimal

Returns a BigDecimal whose value is the absolute value of this BigDecimal, with rounding according to the context settings.

Link copied to clipboard
open operator override fun compareTo(other: BigDecimal): Int

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.

Link copied to clipboard
open operator override fun div(divisor: BigDecimal): BigDecimal

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.

open override fun div(divisor: BigDecimal, mc: MathContext): BigDecimal

Returns a BigDecimal whose value is (this / divisor), with rounding according to the context settings.

Link copied to clipboard
open override fun divideAndRemainder(divisor: BigDecimal): Pair<BigDecimal, BigDecimal>

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.

Link copied to clipboard
open override fun divideToIntegralValue(divisor: BigDecimal): BigDecimal

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()).

open override fun divideToIntegralValue(divisor: BigDecimal, mc: MathContext): BigDecimal

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.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun max(val: BigDecimal): BigDecimal

Returns the maximum of this BigDecimal and val.

Link copied to clipboard
open override fun min(val: BigDecimal): BigDecimal

Returns the minimum of this BigDecimal and val.

Link copied to clipboard
open operator override fun minus(subtrahend: BigDecimal): BigDecimal

Returns a BigDecimal whose value is (this - subtrahend), and whose _scale is max(this._scale(), subtrahend._scale()).

open override fun minus(subtrahend: BigDecimal, mc: MathContext): BigDecimal

Returns a BigDecimal whose value is (this - subtrahend), with rounding according to the context settings.

Link copied to clipboard
open override fun movePointLeft(n: Int): BigDecimal

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).

Link copied to clipboard
open override fun movePointRight(n: Int): BigDecimal

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).

Link copied to clipboard
open operator override fun plus(augend: BigDecimal?): BigDecimal

Returns a BigDecimal whose value is (this + augend), and whose _scale is max(this._scale(), augend._scale()).

open override fun plus(augend: BigDecimal?, mc: MathContext): BigDecimal

Returns a BigDecimal whose value is (this + augend), with rounding according to the context settings.

Link copied to clipboard
open infix override fun pow(n: Int): BigDecimal

Returns a BigDecimal whose value is (this<sup>n</sup>), The power is computed exactly, to unlimited _precision.

open override fun pow(n: Int, mc: MathContext): BigDecimal

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.

Link copied to clipboard
open operator override fun rem(divisor: BigDecimal): BigDecimal

Returns a BigDecimal whose value is (this % divisor).

open override fun rem(divisor: BigDecimal, mc: MathContext): BigDecimal

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.

Link copied to clipboard
open override fun round(mc: MathContext): BigDecimal

Returns a BigDecimal rounded according to the MathContext settings. If the _precision setting is 0 then no rounding takes place.

Link copied to clipboard
open override fun scaleByPowerOfTen(n: Int): BigDecimal

Returns a BigDecimal whose numerical value is equal to (this * 10n). The _scale of the result is (this._scale() - n).

Link copied to clipboard
open override fun setScale(newScale: Int): BigDecimal

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.

open override fun setScale(newScale: Int, roundingMode: Int): BigDecimal
open override fun setScale(newScale: Int, roundingMode: RoundingMode): BigDecimal

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.

Link copied to clipboard
open override fun sqrt(mc: MathContext): BigDecimal

Returns an approximation to the square root of this with rounding according to the context settings.

Link copied to clipboard
open override fun stripTrailingZeros(): BigDecimal

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.

Link copied to clipboard
open operator override fun times(multiplicand: BigDecimal?): BigDecimal

Returns a BigDecimal whose value is (this multiplicand), and whose _scale is (this._scale() + multiplicand._scale()).

open override fun times(multiplicand: BigDecimal, mc: MathContext): BigDecimal

Returns a BigDecimal whose value is (this multiplicand), with rounding according to the context settings.

Link copied to clipboard
open override fun toBigInteger(): BigInteger

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.

Link copied to clipboard
open override fun toBigIntegerExact(): BigInteger

Converts this BigDecimal to a BigInteger, checking for lost information. An exception is thrown if this BigDecimal has a nonzero fractional part.

Link copied to clipboard
open override fun toByte(): Byte
Link copied to clipboard
open override fun toByteExact(): Byte

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.

Link copied to clipboard
open override fun toChar(): Char
Link copied to clipboard
open override fun toDouble(): Double

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.

Link copied to clipboard
open override fun toEngineeringString(): String

Returns a string representation of this BigDecimal, using engineering notation if an exponent is needed.

Link copied to clipboard
open override fun toFloat(): Float

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.

Link copied to clipboard
open override fun toInt(): Int

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.

Link copied to clipboard
open override fun toIntExact(): Int

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.

Link copied to clipboard
Link copied to clipboard
open override fun toLong(): Long

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.

Link copied to clipboard
open override fun toLongExact(): Long

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.

Link copied to clipboard
open override fun toPlainString(): String

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.

Link copied to clipboard
open override fun toShort(): Short
Link copied to clipboard
open override fun toShortExact(): Short

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.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open override fun ulp(): BigDecimal

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()].

Link copied to clipboard
open operator override fun unaryMinus(): BigDecimal

Returns a BigDecimal whose value is (-this), and whose _scale is this._scale().

open override fun unaryMinus(mc: MathContext): BigDecimal

Returns a BigDecimal whose value is (-this), with rounding according to the context settings.

Link copied to clipboard
open operator override fun unaryPlus(): BigDecimal

Returns a BigDecimal whose value is (+this), and whose _scale is this._scale().

open override fun unaryPlus(mc: MathContext): BigDecimal

Returns a BigDecimal whose value is (+this), with rounding according to the context settings.