Java java.math BigDecimal fields, constructors, methods, implement or subclass

Example usage for Java java.math BigDecimal fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for java.math BigDecimal.

The text is from its open source code.

Field

intscale
The scale of this BigDecimal, as returned by #scale .
intprecision
The number of decimal digits in this BigDecimal, or 0 if the number of digits are not known (lookaside information).
BigDecimalZERO
The value 0, with a scale of 0.
BigDecimalONE
The value 1, with a scale of 0.
BigDecimalTEN
The value 10, with a scale of 0.
intROUND_UP
Rounding mode to round away from zero.
intROUND_DOWN
Rounding mode to round towards zero.
intROUND_CEILING
Rounding mode to round towards positive infinity.
intROUND_FLOOR
Rounding mode to round towards negative infinity.
intROUND_HALF_UP
Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round up.
intROUND_HALF_DOWN
Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round down.
intROUND_HALF_EVEN
Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, in which case, round towards the even neighbor.
intROUND_UNNECESSARY
Rounding mode to assert that the requested operation has an exact result, hence no rounding is necessary.

Constructor

BigDecimal(char[] in)
Translates a character array representation of a BigDecimal into a BigDecimal , accepting the same sequence of characters as the #BigDecimal(String) constructor.
BigDecimal(String val)
Translates the string representation of a BigDecimal into a BigDecimal .
BigDecimal(double val)
Translates a double into a BigDecimal which is the exact decimal representation of the double 's binary floating-point value.
BigDecimal(BigInteger val)
Translates a BigInteger into a BigDecimal .
BigDecimal(int val)
Translates an int into a BigDecimal .
BigDecimal(long val)
Translates a long into a BigDecimal .
BigDecimal(char[] in, MathContext mc)
Translates a character array representation of a BigDecimal into a BigDecimal , accepting the same sequence of characters as the #BigDecimal(String) constructor and with rounding according to the context settings.
BigDecimal(String val, MathContext mc)
Translates the string representation of a BigDecimal into a BigDecimal , accepting the same strings as the #BigDecimal(String) constructor, with rounding according to the context settings.
BigDecimal(double val, MathContext mc)
Translates a double into a BigDecimal , with rounding according to the context settings.
BigDecimal(BigInteger val, MathContext mc)
Translates a BigInteger into a BigDecimal rounding according to the context settings.
BigDecimal(BigInteger unscaledVal, int scale)
Translates a BigInteger unscaled value and an int scale into a BigDecimal .
BigDecimal(int val, MathContext mc)
Translates an int into a BigDecimal , with rounding according to the context settings.
BigDecimal(long val, MathContext mc)
Translates a long into a BigDecimal , with rounding according to the context settings.
BigDecimal(char[] in, int offset, int len)
Translates a character array representation of a BigDecimal into a BigDecimal , accepting the same sequence of characters as the #BigDecimal(String) constructor, while allowing a sub-array to be specified.
BigDecimal(BigInteger unscaledVal, int scale, MathContext mc)
Translates a BigInteger unscaled value and an int scale into a BigDecimal , with rounding according to the context settings.
BigDecimal(BigInteger intVal, long val, int scale, int prec)
Trusted package private constructor.
BigDecimal(char[] in, int offset, int len, MathContext mc)
Translates a character array representation of a BigDecimal into a BigDecimal , accepting the same sequence of characters as the #BigDecimal(String) constructor, while allowing a sub-array to be specified and with rounding according to the context settings.

Method

BigDecimalabs(MathContext mc)
Returns a BigDecimal whose value is the absolute value of this BigDecimal , with rounding according to the context settings.
BigDecimalabs()
Returns a BigDecimal whose value is the absolute value of this BigDecimal , and whose scale is this.scale() .
BigDecimaladd(BigDecimal augend)
Returns a BigDecimal whose value is (this + augend) , and whose scale is max(this.scale(), augend.scale()) .
BigDecimaladd(BigDecimal augend, MathContext mc)
Returns a BigDecimal whose value is (this + augend) , with rounding according to the context settings.
longadd(long xs, long ys)
bytebyteValue()
Returns the value of the specified number as a byte .
bytebyteValueExact()
Converts this BigDecimal to a byte , checking for lost information.
intcompareTo(BigDecimal val)
Compares this BigDecimal with the specified BigDecimal .
BigDecimaldivide(BigDecimal divisor)
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.
BigDecimaldivide(BigDecimal divisor, int roundingMode)
Returns a BigDecimal whose value is (this / divisor) , and whose scale is this.scale() .
BigDecimaldivide(BigDecimal divisor, RoundingMode roundingMode)
Returns a BigDecimal whose value is (this / divisor) , and whose scale is this.scale() .
BigDecimaldivide(BigDecimal divisor, MathContext mc)
Returns a BigDecimal whose value is (this / divisor) , with rounding according to the context settings.
BigDecimaldivide(BigDecimal divisor, int scale, int roundingMode)
Returns a BigDecimal whose value is (this / divisor) , and whose scale is as specified.
BigDecimaldivide(BigDecimal divisor, int scale, RoundingMode roundingMode)
Returns a BigDecimal whose value is (this / divisor) , and whose scale is as specified.
BigDecimal[]divideAndRemainder(BigDecimal divisor)
Returns a two-element BigDecimal array containing the result of divideToIntegralValue followed by the result of remainder on the two operands.
BigDecimal[]divideAndRemainder(BigDecimal divisor, MathContext mc)
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.
BigDecimaldivideToIntegralValue(BigDecimal divisor)
Returns a BigDecimal whose value is the integer part of the quotient (this / divisor) rounded down.
BigDecimaldivideToIntegralValue(BigDecimal divisor, MathContext mc)
Returns a BigDecimal whose value is the integer part of (this / divisor) .
doubledoubleValue()
Converts this BigDecimal to a double .
booleanequals(Object x)
Compares this BigDecimal with the specified Object for equality.
floatfloatValue()
Converts this BigDecimal to a float .
ClassgetClass()
Returns the runtime class of this Object .
inthashCode()
Returns the hash code for this BigDecimal .
intintValue()
Converts this BigDecimal to an int .
intintValueExact()
Converts this BigDecimal to an int , checking for lost information.
longlongValue()
Converts this BigDecimal to a long .
longlongValueExact()
Converts this BigDecimal to a long , checking for lost information.
BigDecimalmax(BigDecimal val)
Returns the maximum of this BigDecimal and val .
BigDecimalmin(BigDecimal val)
Returns the minimum of this BigDecimal and val .
BigDecimalmovePointLeft(int n)
Returns a BigDecimal which is equivalent to this one with the decimal point moved n places to the left.
BigDecimalmovePointRight(int n)
Returns a BigDecimal which is equivalent to this one with the decimal point moved n places to the right.
BigDecimalmultiply(BigDecimal multiplicand)
Returns a BigDecimal whose value is (this × multiplicand), and whose scale is (this.scale() + multiplicand.scale()) .
BigDecimalmultiply(BigDecimal multiplicand, MathContext mc)
Returns a BigDecimal whose value is (this × multiplicand), with rounding according to the context settings.
longmultiply(long x, long y)
BigDecimalnegate()
Returns a BigDecimal whose value is (-this) , and whose scale is this.scale() .
BigDecimalnegate(MathContext mc)
Returns a BigDecimal whose value is (-this) , with rounding according to the context settings.
BigDecimalplus()
Returns a BigDecimal whose value is (+this) , and whose scale is this.scale() .
BigDecimalplus(MathContext mc)
Returns a BigDecimal whose value is (+this) , with rounding according to the context settings.
BigDecimalpow(int n, MathContext mc)
Returns a BigDecimal whose value is (thisn).
BigDecimalpow(int n)
Returns a BigDecimal whose value is (thisn), The power is computed exactly, to unlimited precision.
BigDecimalremainder(BigDecimal divisor)
Returns a BigDecimal whose value is (this % divisor) .
BigDecimalround(MathContext mc)
Returns a BigDecimal rounded according to the MathContext settings.
BigDecimalscaleByPowerOfTen(int n)
Returns a BigDecimal whose numerical value is equal to ( this * 10n).
BigDecimalsetScale(int newScale, RoundingMode roundingMode)
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.
BigDecimalsetScale(int newScale, int roundingMode)
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.
BigDecimalsetScale(int newScale)
Returns a BigDecimal whose scale is the specified value, and whose value is numerically equal to this BigDecimal 's.
shortshortValue()
Returns the value of the specified number as a short .
shortshortValueExact()
Converts this BigDecimal to a short , checking for lost information.
intsignum()
Returns the signum function of this BigDecimal .
BigDecimalstripTrailingZeros()
Returns a BigDecimal which is numerically equal to this one but with any trailing zeros removed from the representation.
BigDecimalsubtract(BigDecimal subtrahend)
Returns a BigDecimal whose value is (this - subtrahend) , and whose scale is max(this.scale(), subtrahend.scale()) .
BigDecimalsubtract(BigDecimal subtrahend, MathContext mc)
Returns a BigDecimal whose value is (this - subtrahend) , with rounding according to the context settings.
BigIntegertoBigInteger()
Converts this BigDecimal to a BigInteger .
BigIntegertoBigIntegerExact()
Converts this BigDecimal to a BigInteger , checking for lost information.
StringtoEngineeringString()
Returns a string representation of this BigDecimal , using engineering notation if an exponent is needed.
StringtoPlainString()
Returns a string representation of this BigDecimal without an exponent field.
StringtoString()
Returns the string representation of this BigDecimal , using scientific notation if an exponent is needed.
BigDecimalulp()
Returns the size of an ulp, a unit in the last place, of this BigDecimal .
BigIntegerunscaledValue()
Returns a BigInteger whose value is the unscaled value of this BigDecimal .
BigDecimalvalueOf(long val)
Translates a long value into a BigDecimal with a scale of zero.
BigDecimalvalueOf(double val)
Translates a double into a BigDecimal , using the double 's canonical string representation provided by the Double#toString(double) method.
BigDecimalvalueOf(long unscaledVal, int scale)
Translates a long unscaled value and an int scale into a BigDecimal .