Uses of Class
java.math.BigDecimal
Packages that useBigDecimal
Package
Description
Provides classes for performing arbitrary-precision integer arithmetic (
BigInteger) and arbitrary-precision decimal arithmetic (BigDecimal).Provides the API for accessing and processing data stored in a data source (usually a relational database) using the Java programming language.
Contains the collections framework, some internationalization support classes, a service loader, properties, random number generation, string parsing and scanning classes, base64 encoding and decoding, a bit array, and several miscellaneous utility classes.
Provides the open data types and Open MBean descriptor classes.
Provides the API for server side data source access and processing from the Java programming language.
Standard interfaces and base classes for JDBC
RowSet implementations.Provides utility classes to allow serializable mappings between SQL types and data types in the Java programming language.
Defines XML/Java Type Mappings.
Incubating Feature. Will be removed in a future release.
Uses ofBigDecimal injava.math
Classes injava.math that implement interfaces with type arguments of typeBigDecimalModifier and TypeClassDescriptionclassImmutable, arbitrary-precision signed decimal numbers.Fields injava.math declared asBigDecimalModifier and TypeFieldDescriptionstatic finalBigDecimalBigDecimal.ONEThe value 1, with a scale of 0.static finalBigDecimalBigDecimal.TENThe value 10, with a scale of 0.static finalBigDecimalBigDecimal.TWOThe value 2, with a scale of 0.static finalBigDecimalBigDecimal.ZEROThe value 0, with a scale of 0.Methods injava.math that returnBigDecimalModifier and TypeMethodDescriptionBigDecimal.abs()Returns aBigDecimalwhose value is the absolute value of thisBigDecimal, and whose scale isthis.scale().BigDecimal.abs(MathContext mc) Returns aBigDecimalwhose value is the absolute value of thisBigDecimal, with rounding according to the context settings.BigDecimal.add(BigDecimal augend) Returns aBigDecimalwhose value is(this + augend), and whose scale ismax(this.scale(), augend.scale()).BigDecimal.add(BigDecimal augend,MathContext mc) Returns aBigDecimalwhose value is(this + augend), with rounding according to the context settings.BigDecimal.divide(BigDecimal divisor) Returns aBigDecimalwhose 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) anArithmeticExceptionis thrown.BigDecimal.divide(BigDecimal divisor, int roundingMode) Deprecated.The methoddivide(BigDecimal, RoundingMode)should be used in preference to this legacy method.BigDecimal.divide(BigDecimal divisor, int scale, int roundingMode) Deprecated.The methoddivide(BigDecimal, int, RoundingMode)should be used in preference to this legacy method.BigDecimal.divide(BigDecimal divisor, int scale,RoundingMode roundingMode) Returns aBigDecimalwhose value is(this / divisor), and whose scale is as specified.BigDecimal.divide(BigDecimal divisor,MathContext mc) Returns aBigDecimalwhose value is(this / divisor), with rounding according to the context settings.BigDecimal.divide(BigDecimal divisor,RoundingMode roundingMode) Returns aBigDecimalwhose value is(this / divisor), and whose scale isthis.scale().BigDecimal.divideAndRemainder(BigDecimal divisor) Returns a two-elementBigDecimalarray containing the result ofdivideToIntegralValuefollowed by the result ofremainderon the two operands.BigDecimal.divideAndRemainder(BigDecimal divisor,MathContext mc) Returns a two-elementBigDecimalarray containing the result ofdivideToIntegralValuefollowed by the result ofremainderon the two operands calculated with rounding according to the context settings.BigDecimal.divideToIntegralValue(BigDecimal divisor) Returns aBigDecimalwhose value is the integer part of the quotient(this / divisor)rounded down.BigDecimal.divideToIntegralValue(BigDecimal divisor,MathContext mc) Returns aBigDecimalwhose value is the integer part of(this / divisor).BigDecimal.max(BigDecimal val) Returns the maximum of thisBigDecimalandval.BigDecimal.min(BigDecimal val) Returns the minimum of thisBigDecimalandval.BigDecimal.movePointLeft(int n) Returns aBigDecimalwhich is equivalent to this one with the decimal point movednplaces to the left.BigDecimal.movePointRight(int n) Returns aBigDecimalwhich is equivalent to this one with the decimal point movednplaces to the right.BigDecimal.multiply(BigDecimal multiplicand) Returns aBigDecimalwhose value is(this × multiplicand), and whose scale is(this.scale() + multiplicand.scale()).BigDecimal.multiply(BigDecimal multiplicand,MathContext mc) Returns aBigDecimalwhose value is(this × multiplicand), with rounding according to the context settings.BigDecimal.negate()Returns aBigDecimalwhose value is(-this), and whose scale isthis.scale().BigDecimal.negate(MathContext mc) Returns aBigDecimalwhose value is(-this), with rounding according to the context settings.BigDecimal.plus()Returns aBigDecimalwhose value is(+this), and whose scale isthis.scale().BigDecimal.plus(MathContext mc) Returns aBigDecimalwhose value is(+this), with rounding according to the context settings.BigDecimal.pow(int n) Returns aBigDecimalwhose value is(thisn), The power is computed exactly, to unlimited precision.BigDecimal.pow(int n,MathContext mc) Returns aBigDecimalwhose value is(thisn).BigDecimal.remainder(BigDecimal divisor) Returns aBigDecimalwhose value is(this % divisor).BigDecimal.remainder(BigDecimal divisor,MathContext mc) Returns aBigDecimalwhose value is(this % divisor), with rounding according to the context settings.BigDecimal.round(MathContext mc) Returns aBigDecimalrounded according to theMathContextsettings.BigDecimal.scaleByPowerOfTen(int n) Returns a BigDecimal whose numerical value is equal to (this* 10n).BigDecimal.setScale(int newScale) Returns aBigDecimalwhose scale is the specified value, and whose value is numerically equal to thisBigDecimal's.BigDecimal.setScale(int newScale, int roundingMode) Deprecated.The methodsetScale(int, RoundingMode)should be used in preference to this legacy method.BigDecimal.setScale(int newScale,RoundingMode roundingMode) Returns aBigDecimalwhose scale is the specified value, and whose unscaled value is determined by multiplying or dividing thisBigDecimal's unscaled value by the appropriate power of ten to maintain its overall value.BigDecimal.sqrt(MathContext mc) Returns an approximation to the square root ofthiswith rounding according to the context settings.BigDecimal.stripTrailingZeros()Returns aBigDecimalwhich is numerically equal to this one but with any trailing zeros removed from the representation.BigDecimal.subtract(BigDecimal subtrahend) Returns aBigDecimalwhose value is(this - subtrahend), and whose scale ismax(this.scale(), subtrahend.scale()).BigDecimal.subtract(BigDecimal subtrahend,MathContext mc) Returns aBigDecimalwhose value is(this - subtrahend), with rounding according to the context settings.BigDecimal.ulp()Returns the size of an ulp, a unit in the last place, of thisBigDecimal.staticBigDecimalBigDecimal.valueOf(double val) Translates adoubleinto aBigDecimal, using thedouble's canonical string representation provided by theDouble.toString(double)method.staticBigDecimalBigDecimal.valueOf(long val) Translates alongvalue into aBigDecimalwith a scale of zero.staticBigDecimalBigDecimal.valueOf(long unscaledVal, int scale) Translates alongunscaled value and anintscale into aBigDecimal.Methods injava.math with parameters of typeBigDecimalModifier and TypeMethodDescriptionBigDecimal.add(BigDecimal augend) Returns aBigDecimalwhose value is(this + augend), and whose scale ismax(this.scale(), augend.scale()).BigDecimal.add(BigDecimal augend,MathContext mc) Returns aBigDecimalwhose value is(this + augend), with rounding according to the context settings.intBigDecimal.compareTo(BigDecimal val) Compares thisBigDecimalnumerically with the specifiedBigDecimal.BigDecimal.divide(BigDecimal divisor) Returns aBigDecimalwhose 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) anArithmeticExceptionis thrown.BigDecimal.divide(BigDecimal divisor, int roundingMode) Deprecated.The methoddivide(BigDecimal, RoundingMode)should be used in preference to this legacy method.BigDecimal.divide(BigDecimal divisor, int scale, int roundingMode) Deprecated.The methoddivide(BigDecimal, int, RoundingMode)should be used in preference to this legacy method.BigDecimal.divide(BigDecimal divisor, int scale,RoundingMode roundingMode) Returns aBigDecimalwhose value is(this / divisor), and whose scale is as specified.BigDecimal.divide(BigDecimal divisor,MathContext mc) Returns aBigDecimalwhose value is(this / divisor), with rounding according to the context settings.BigDecimal.divide(BigDecimal divisor,RoundingMode roundingMode) Returns aBigDecimalwhose value is(this / divisor), and whose scale isthis.scale().BigDecimal.divideAndRemainder(BigDecimal divisor) Returns a two-elementBigDecimalarray containing the result ofdivideToIntegralValuefollowed by the result ofremainderon the two operands.BigDecimal.divideAndRemainder(BigDecimal divisor,MathContext mc) Returns a two-elementBigDecimalarray containing the result ofdivideToIntegralValuefollowed by the result ofremainderon the two operands calculated with rounding according to the context settings.BigDecimal.divideToIntegralValue(BigDecimal divisor) Returns aBigDecimalwhose value is the integer part of the quotient(this / divisor)rounded down.BigDecimal.divideToIntegralValue(BigDecimal divisor,MathContext mc) Returns aBigDecimalwhose value is the integer part of(this / divisor).BigDecimal.max(BigDecimal val) Returns the maximum of thisBigDecimalandval.BigDecimal.min(BigDecimal val) Returns the minimum of thisBigDecimalandval.BigDecimal.multiply(BigDecimal multiplicand) Returns aBigDecimalwhose value is(this × multiplicand), and whose scale is(this.scale() + multiplicand.scale()).BigDecimal.multiply(BigDecimal multiplicand,MathContext mc) Returns aBigDecimalwhose value is(this × multiplicand), with rounding according to the context settings.BigDecimal.remainder(BigDecimal divisor) Returns aBigDecimalwhose value is(this % divisor).BigDecimal.remainder(BigDecimal divisor,MathContext mc) Returns aBigDecimalwhose value is(this % divisor), with rounding according to the context settings.BigDecimal.subtract(BigDecimal subtrahend) Returns aBigDecimalwhose value is(this - subtrahend), and whose scale ismax(this.scale(), subtrahend.scale()).BigDecimal.subtract(BigDecimal subtrahend,MathContext mc) Returns aBigDecimalwhose value is(this - subtrahend), with rounding according to the context settings.Uses ofBigDecimal injava.sql
Methods injava.sql that returnBigDecimalModifier and TypeMethodDescriptionCallableStatement.getBigDecimal(int parameterIndex) Retrieves the value of the designated JDBCNUMERICparameter as ajava.math.BigDecimalobject with as many digits to the right of the decimal point as the value contains.CallableStatement.getBigDecimal(int parameterIndex, int scale) Deprecated.usegetBigDecimal(int parameterIndex)orgetBigDecimal(String parameterName)CallableStatement.getBigDecimal(String parameterName) Retrieves the value of a JDBCNUMERICparameter as ajava.math.BigDecimalobject with as many digits to the right of the decimal point as the value contains.ResultSet.getBigDecimal(int columnIndex) Retrieves the value of the designated column in the current row of thisResultSetobject as ajava.math.BigDecimalwith full precision.ResultSet.getBigDecimal(int columnIndex, int scale) Deprecated.UsegetBigDecimal(int columnIndex)orgetBigDecimal(String columnLabel)ResultSet.getBigDecimal(String columnLabel) Retrieves the value of the designated column in the current row of thisResultSetobject as ajava.math.BigDecimalwith full precision.ResultSet.getBigDecimal(String columnLabel, int scale) Deprecated.UsegetBigDecimal(int columnIndex)orgetBigDecimal(String columnLabel)SQLInput.readBigDecimal()Reads the next attribute in the stream and returns it as ajava.math.BigDecimalobject in the Java programming language.Methods injava.sql with parameters of typeBigDecimalModifier and TypeMethodDescriptionvoidCallableStatement.setBigDecimal(String parameterName,BigDecimal x) Sets the designated parameter to the givenjava.math.BigDecimalvalue.voidPreparedStatement.setBigDecimal(int parameterIndex,BigDecimal x) Sets the designated parameter to the givenjava.math.BigDecimalvalue.voidResultSet.updateBigDecimal(int columnIndex,BigDecimal x) Updates the designated column with ajava.math.BigDecimalvalue.voidResultSet.updateBigDecimal(String columnLabel,BigDecimal x) Updates the designated column with ajava.sql.BigDecimalvalue.voidSQLOutput.writeBigDecimal(BigDecimal x) Writes the next attribute to the stream as a java.math.BigDecimal object.Uses ofBigDecimal injava.util
Methods injava.util that returnBigDecimalModifier and TypeMethodDescriptionScanner.nextBigDecimal()Scans the next token of the input as aBigDecimal.Uses ofBigDecimal injavax.management.openmbean
Fields injavax.management.openmbean with type parameters of typeBigDecimalModifier and TypeFieldDescriptionstatic finalSimpleType<BigDecimal> SimpleType.BIGDECIMALTheSimpleTypeinstance describing values whose Java class name isjava.math.BigDecimal.Uses ofBigDecimal injavax.sql
Methods injavax.sql with parameters of typeBigDecimalModifier and TypeMethodDescriptionvoidRowSet.setBigDecimal(int parameterIndex,BigDecimal x) Sets the designated parameter in thisRowSetobject's command to the givenjava.math.BigDecimalvalue.voidRowSet.setBigDecimal(String parameterName,BigDecimal x) Sets the designated parameter to the givenjava.math.BigDecimalvalue.Uses ofBigDecimal injavax.sql.rowset
Methods injavax.sql.rowset with parameters of typeBigDecimalModifier and TypeMethodDescriptionvoidBaseRowSet.setBigDecimal(int parameterIndex,BigDecimal x) Sets the designated parameter to the givenjava.math.BigDecimalvalue.voidBaseRowSet.setBigDecimal(String parameterName,BigDecimal x) Sets the designated parameter to the givenjava.math.BigDecimalvalue.Uses ofBigDecimal injavax.sql.rowset.serial
Methods injavax.sql.rowset.serial that returnBigDecimalModifier and TypeMethodDescriptionSQLInputImpl.readBigDecimal()Retrieves the next attribute in thisSQLInputImplobject as ajava.math.BigDecimal.Methods injavax.sql.rowset.serial with parameters of typeBigDecimalModifier and TypeMethodDescriptionvoidSQLOutputImpl.writeBigDecimal(BigDecimal x) Writes ajava.math.BigDecimalobject in the Java programming language to thisSQLOutputImplobject.Uses ofBigDecimal injavax.xml.datatype
Methods injavax.xml.datatype that returnBigDecimalModifier and TypeMethodDescriptionabstractBigDecimalXMLGregorianCalendar.getFractionalSecond()Returns fractional seconds.Methods injavax.xml.datatype with parameters of typeBigDecimalModifier and TypeMethodDescriptionabstractDurationDuration.multiply(BigDecimal factor) Computes a new duration whose value isfactortimes longer than the value of this duration.abstractDurationDatatypeFactory.newDuration(boolean isPositive,BigInteger years,BigInteger months,BigInteger days,BigInteger hours,BigInteger minutes,BigDecimal seconds) Obtain a new instance of aDurationspecifying theDurationas isPositive, years, months, days, hours, minutes, seconds.abstractXMLGregorianCalendarDatatypeFactory.newXMLGregorianCalendar(BigInteger year, int month, int day, int hour, int minute, int second,BigDecimal fractionalSecond, int timezone) Constructor allowing for complete value spaces allowed by W3C XML Schema 1.0 recommendation for xsd:dateTime and related builtin datatypes.DatatypeFactory.newXMLGregorianCalendarTime(int hours, int minutes, int seconds,BigDecimal fractionalSecond, int timezone) Create a Java instance of XML Schema builtin datatype time.abstract voidXMLGregorianCalendar.setFractionalSecond(BigDecimal fractional) Set fractional seconds.voidXMLGregorianCalendar.setTime(int hour, int minute, int second,BigDecimal fractional) Set time as one unit, including the optional infinite precision fractional seconds.Uses ofBigDecimal injdk.incubator.vector
Methods injdk.incubator.vector with parameters of typeBigDecimalModifier and TypeMethodDescriptionstaticFloat16Float16.valueOf(BigDecimal v) Returns aFloat16value rounded from theBigDecimalargument using the round to nearest rounding policy.