Uses of Class java.math.BigDecimal (Java SE 26 & JDK 26)
Description: use: module: java.base, package: java.math, class: BigDecimal

# Uses of Class
java.math.BigDecimal

Packages that use BigDecimal
Package
Description
java.math
Provides classes for performing arbitrary-precision integer arithmetic (`BigInteger`) and arbitrary-precision decimal arithmetic (`BigDecimal`).
java.sql
Provides the API for accessing and processing data stored in a data source (usually a relational database) using the Java programming language.
java.util
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.
javax.management.openmbean
Provides the open data types and Open MBean descriptor classes.
javax.sql
Provides the API for server side data source access and processing from the Java programming language.
javax.sql.rowset
Standard interfaces and base classes for JDBC `RowSet` implementations.
javax.sql.rowset.serial
Provides utility classes to allow serializable mappings between SQL types and data types in the Java programming language.
javax.xml.datatype
Defines XML/Java Type Mappings.
jdk.incubator.vector
Incubating Feature. Will be removed in a future release.

- ## Uses of BigDecimal in java.math

  Classes in java.math that implement interfaces with type arguments of type BigDecimal
  Modifier and Type
  Class
  Description
  `class`
  `BigDecimal`
  Immutable, arbitrary-precision signed decimal numbers.
  Fields in java.math declared as BigDecimal
  Modifier and Type
  Field
  Description
  `static final BigDecimal`
  BigDecimal.`ONE`
  The value 1, with a scale of 0.
  `static final BigDecimal`
  BigDecimal.`TEN`
  The value 10, with a scale of 0.
  `static final BigDecimal`
  BigDecimal.`TWO`
  The value 2, with a scale of 0.
  `static final BigDecimal`
  BigDecimal.`ZERO`
  The value 0, with a scale of 0.
  Methods in java.math that return BigDecimal
  Modifier and Type
  Method
  Description
  `BigDecimal`
  BigDecimal.`abs()`
  Returns a `BigDecimal` whose value is the absolute value of this `BigDecimal`, and whose scale is `this.scale()`.
  `BigDecimal`
  BigDecimal.`abs(MathContext mc)`
  Returns a `BigDecimal` whose value is the absolute value of this `BigDecimal`, with rounding according to the context settings.
  `BigDecimal`
  BigDecimal.`add(BigDecimal augend)`
  Returns a `BigDecimal` whose value is `(this + augend)`, and whose scale is `max(this.scale(), augend.scale())`.
  `BigDecimal`
  BigDecimal.`add(BigDecimal augend, MathContext mc)`
  Returns a `BigDecimal` whose value is `(this + augend)`, with rounding according to the context settings.
  `BigDecimal`
  BigDecimal.`divide(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.
  `BigDecimal`
  BigDecimal.`divide(BigDecimal divisor, int roundingMode)`
  Deprecated.
  The method `BigDecimal.divide(BigDecimal, RoundingMode)` should be used in preference to this legacy method.
  `BigDecimal`
  BigDecimal.`divide(BigDecimal divisor, int scale, int roundingMode)`
  Deprecated.
  The method `BigDecimal.divide(BigDecimal, int, RoundingMode)` should be used in preference to this legacy method.
  `BigDecimal`
  BigDecimal.`divide(BigDecimal divisor, int scale, RoundingMode roundingMode)`
  Returns a `BigDecimal` whose value is `(this / divisor)`, and whose scale is as specified.
  `BigDecimal`
  BigDecimal.`divide(BigDecimal divisor, MathContext mc)`
  Returns a `BigDecimal` whose value is `(this / divisor)`, with rounding according to the context settings.
  `BigDecimal`
  BigDecimal.`divide(BigDecimal divisor, RoundingMode roundingMode)`
  Returns a `BigDecimal` whose value is `(this / divisor)`, and whose scale is `this.scale()`.
  `BigDecimal[]`
  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[]`
  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.
  `BigDecimal`
  BigDecimal.`divideToIntegralValue(BigDecimal divisor)`
  Returns a `BigDecimal` whose value is the integer part of the quotient `(this / divisor)` rounded down.
  `BigDecimal`
  BigDecimal.`divideToIntegralValue(BigDecimal divisor, MathContext mc)`
  Returns a `BigDecimal` whose value is the integer part of `(this / divisor)`.
  `BigDecimal`
  BigDecimal.`max(BigDecimal val)`
  Returns the maximum of this `BigDecimal` and `val`.
  `BigDecimal`
  BigDecimal.`min(BigDecimal val)`
  Returns the minimum of this `BigDecimal` and `val`.
  `BigDecimal`
  BigDecimal.`movePointLeft(int n)`
  Returns a `BigDecimal` which is equivalent to this one with the decimal point moved `n` places to the left.
  `BigDecimal`
  BigDecimal.`movePointRight(int n)`
  Returns a `BigDecimal` which is equivalent to this one with the decimal point moved `n` places to the right.
  `BigDecimal`
  BigDecimal.`multiply(BigDecimal multiplicand)`
  Returns a `BigDecimal` whose value is `(this × multiplicand)`, and whose scale is `(this.scale() + multiplicand.scale())`.
  `BigDecimal`
  BigDecimal.`multiply(BigDecimal multiplicand, MathContext mc)`
  Returns a `BigDecimal` whose value is `(this × multiplicand)`, with rounding according to the context settings.
  `BigDecimal`
  BigDecimal.`negate()`
  Returns a `BigDecimal` whose value is `(-this)`, and whose scale is `this.scale()`.
  `BigDecimal`
  BigDecimal.`negate(MathContext mc)`
  Returns a `BigDecimal` whose value is `(-this)`, with rounding according to the context settings.
  `BigDecimal`
  BigDecimal.`plus()`
  Returns a `BigDecimal` whose value is `(+this)`, and whose scale is `this.scale()`.
  `BigDecimal`
  BigDecimal.`plus(MathContext mc)`
  Returns a `BigDecimal` whose value is `(+this)`, with rounding according to the context settings.
  `BigDecimal`
  BigDecimal.`pow(int n)`
  Returns a `BigDecimal` whose value is `(thisn)`, The power is computed exactly, to unlimited precision.
  `BigDecimal`
  BigDecimal.`pow(int n, MathContext mc)`
  Returns a `BigDecimal` whose value is `(thisn)`.
  `BigDecimal`
  BigDecimal.`remainder(BigDecimal divisor)`
  Returns a `BigDecimal` whose value is `(this % divisor)`.
  `BigDecimal`
  BigDecimal.`remainder(BigDecimal divisor, MathContext mc)`
  Returns a `BigDecimal` whose value is `(this % divisor)`, with rounding according to the context settings.
  `BigDecimal`
  BigDecimal.`round(MathContext mc)`
  Returns a `BigDecimal` rounded according to the `MathContext` settings.
  `BigDecimal`
  BigDecimal.`scaleByPowerOfTen(int n)`
  Returns a BigDecimal whose numerical value is equal to (`this` * 10n).
  `BigDecimal`
  BigDecimal.`setScale(int newScale)`
  Returns a `BigDecimal` whose scale is the specified value, and whose value is numerically equal to this `BigDecimal`'s.
  `BigDecimal`
  BigDecimal.`setScale(int newScale, int roundingMode)`
  Deprecated.
  The method `BigDecimal.setScale(int, RoundingMode)` should be used in preference to this legacy method.
  `BigDecimal`
  BigDecimal.`setScale(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.
  `BigDecimal`
  BigDecimal.`sqrt(MathContext mc)`
  Returns an approximation to the square root of `this` with rounding according to the context settings.
  `BigDecimal`
  BigDecimal.`stripTrailingZeros()`
  Returns a `BigDecimal` which is numerically equal to this one but with any trailing zeros removed from the representation.
  `BigDecimal`
  BigDecimal.`subtract(BigDecimal subtrahend)`
  Returns a `BigDecimal` whose value is `(this - subtrahend)`, and whose scale is `max(this.scale(), subtrahend.scale())`.
  `BigDecimal`
  BigDecimal.`subtract(BigDecimal subtrahend, MathContext mc)`
  Returns a `BigDecimal` whose value is `(this - subtrahend)`, with rounding according to the context settings.
  `BigDecimal`
  BigDecimal.`ulp()`
  Returns the size of an ulp, a unit in the last place, of this `BigDecimal`.
  `static BigDecimal`
  BigDecimal.`valueOf(double val)`
  Translates a `double` into a `BigDecimal`, using the `double`'s canonical string representation provided by the `Double.toString(double)` method.
  `static BigDecimal`
  BigDecimal.`valueOf(long val)`
  Translates a `long` value into a `BigDecimal` with a scale of zero.
  `static BigDecimal`
  BigDecimal.`valueOf(long unscaledVal, int scale)`
  Translates a `long` unscaled value and an `int` scale into a `BigDecimal`.
  Methods in java.math with parameters of type BigDecimal
  Modifier and Type
  Method
  Description
  `BigDecimal`
  BigDecimal.`add(BigDecimal augend)`
  Returns a `BigDecimal` whose value is `(this + augend)`, and whose scale is `max(this.scale(), augend.scale())`.
  `BigDecimal`
  BigDecimal.`add(BigDecimal augend, MathContext mc)`
  Returns a `BigDecimal` whose value is `(this + augend)`, with rounding according to the context settings.
  `int`
  BigDecimal.`compareTo(BigDecimal val)`
  Compares this `BigDecimal` numerically with the specified `BigDecimal`.
  `BigDecimal`
  BigDecimal.`divide(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.
  `BigDecimal`
  BigDecimal.`divide(BigDecimal divisor, int roundingMode)`
  Deprecated.
  The method `BigDecimal.divide(BigDecimal, RoundingMode)` should be used in preference to this legacy method.
  `BigDecimal`
  BigDecimal.`divide(BigDecimal divisor, int scale, int roundingMode)`
  Deprecated.
  The method `BigDecimal.divide(BigDecimal, int, RoundingMode)` should be used in preference to this legacy method.
  `BigDecimal`
  BigDecimal.`divide(BigDecimal divisor, int scale, RoundingMode roundingMode)`
  Returns a `BigDecimal` whose value is `(this / divisor)`, and whose scale is as specified.
  `BigDecimal`
  BigDecimal.`divide(BigDecimal divisor, MathContext mc)`
  Returns a `BigDecimal` whose value is `(this / divisor)`, with rounding according to the context settings.
  `BigDecimal`
  BigDecimal.`divide(BigDecimal divisor, RoundingMode roundingMode)`
  Returns a `BigDecimal` whose value is `(this / divisor)`, and whose scale is `this.scale()`.
  `BigDecimal[]`
  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[]`
  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.
  `BigDecimal`
  BigDecimal.`divideToIntegralValue(BigDecimal divisor)`
  Returns a `BigDecimal` whose value is the integer part of the quotient `(this / divisor)` rounded down.
  `BigDecimal`
  BigDecimal.`divideToIntegralValue(BigDecimal divisor, MathContext mc)`
  Returns a `BigDecimal` whose value is the integer part of `(this / divisor)`.
  `BigDecimal`
  BigDecimal.`max(BigDecimal val)`
  Returns the maximum of this `BigDecimal` and `val`.
  `BigDecimal`
  BigDecimal.`min(BigDecimal val)`
  Returns the minimum of this `BigDecimal` and `val`.
  `BigDecimal`
  BigDecimal.`multiply(BigDecimal multiplicand)`
  Returns a `BigDecimal` whose value is `(this × multiplicand)`, and whose scale is `(this.scale() + multiplicand.scale())`.
  `BigDecimal`
  BigDecimal.`multiply(BigDecimal multiplicand, MathContext mc)`
  Returns a `BigDecimal` whose value is `(this × multiplicand)`, with rounding according to the context settings.
  `BigDecimal`
  BigDecimal.`remainder(BigDecimal divisor)`
  Returns a `BigDecimal` whose value is `(this % divisor)`.
  `BigDecimal`
  BigDecimal.`remainder(BigDecimal divisor, MathContext mc)`
  Returns a `BigDecimal` whose value is `(this % divisor)`, with rounding according to the context settings.
  `BigDecimal`
  BigDecimal.`subtract(BigDecimal subtrahend)`
  Returns a `BigDecimal` whose value is `(this - subtrahend)`, and whose scale is `max(this.scale(), subtrahend.scale())`.
  `BigDecimal`
  BigDecimal.`subtract(BigDecimal subtrahend, MathContext mc)`
  Returns a `BigDecimal` whose value is `(this - subtrahend)`, with rounding according to the context settings.

- ## Uses of BigDecimal in java.sql

  Methods in java.sql that return BigDecimal
  Modifier and Type
  Method
  Description
  `BigDecimal`
  CallableStatement.`getBigDecimal(int parameterIndex)`
  Retrieves the value of the designated JDBC `NUMERIC` parameter as a `java.math.BigDecimal` object with as many digits to the right of the decimal point as the value contains.
  `BigDecimal`
  CallableStatement.`getBigDecimal(int parameterIndex, int scale)`
  Deprecated.
  use `getBigDecimal(int parameterIndex)` or `getBigDecimal(String parameterName)`
  `BigDecimal`
  CallableStatement.`getBigDecimal(String parameterName)`
  Retrieves the value of a JDBC `NUMERIC` parameter as a `java.math.BigDecimal` object with as many digits to the right of the decimal point as the value contains.
  `BigDecimal`
  ResultSet.`getBigDecimal(int columnIndex)`
  Retrieves the value of the designated column in the current row of this `ResultSet` object as a `java.math.BigDecimal` with full precision.
  `BigDecimal`
  ResultSet.`getBigDecimal(int columnIndex, int scale)`
  Deprecated.
  Use `getBigDecimal(int columnIndex)` or `getBigDecimal(String columnLabel)`
  `BigDecimal`
  ResultSet.`getBigDecimal(String columnLabel)`
  Retrieves the value of the designated column in the current row of this `ResultSet` object as a `java.math.BigDecimal` with full precision.
  `BigDecimal`
  ResultSet.`getBigDecimal(String columnLabel, int scale)`
  Deprecated.
  Use `getBigDecimal(int columnIndex)` or `getBigDecimal(String columnLabel)`
  `BigDecimal`
  SQLInput.`readBigDecimal()`
  Reads the next attribute in the stream and returns it as a `java.math.BigDecimal` object in the Java programming language.
  Methods in java.sql with parameters of type BigDecimal
  Modifier and Type
  Method
  Description
  `void`
  CallableStatement.`setBigDecimal(String parameterName, BigDecimal x)`
  Sets the designated parameter to the given `java.math.BigDecimal` value.
  `void`
  PreparedStatement.`setBigDecimal(int parameterIndex, BigDecimal x)`
  Sets the designated parameter to the given `java.math.BigDecimal` value.
  `void`
  ResultSet.`updateBigDecimal(int columnIndex, BigDecimal x)`
  Updates the designated column with a `java.math.BigDecimal` value.
  `void`
  ResultSet.`updateBigDecimal(String columnLabel, BigDecimal x)`
  Updates the designated column with a `java.sql.BigDecimal` value.
  `void`
  SQLOutput.`writeBigDecimal(BigDecimal x)`
  Writes the next attribute to the stream as a java.math.BigDecimal object.

- ## Uses of BigDecimal in java.util

  Methods in java.util that return BigDecimal
  Modifier and Type
  Method
  Description
  `BigDecimal`
  Scanner.`nextBigDecimal()`
  Scans the next token of the input as a `BigDecimal`.

- ## Uses of BigDecimal in javax.management.openmbean

  Fields in javax.management.openmbean with type parameters of type BigDecimal
  Modifier and Type
  Field
  Description
  `static final SimpleType<BigDecimal>`
  SimpleType.`BIGDECIMAL`
  The `SimpleType` instance describing values whose Java class name is `java.math.BigDecimal`.

- ## Uses of BigDecimal in javax.sql

  Methods in javax.sql with parameters of type BigDecimal
  Modifier and Type
  Method
  Description
  `void`
  RowSet.`setBigDecimal(int parameterIndex, BigDecimal x)`
  Sets the designated parameter in this `RowSet` object's command to the given `java.math.BigDecimal` value.
  `void`
  RowSet.`setBigDecimal(String parameterName, BigDecimal x)`
  Sets the designated parameter to the given `java.math.BigDecimal` value.

- ## Uses of BigDecimal in javax.sql.rowset

  Methods in javax.sql.rowset with parameters of type BigDecimal
  Modifier and Type
  Method
  Description
  `void`
  BaseRowSet.`setBigDecimal(int parameterIndex, BigDecimal x)`
  Sets the designated parameter to the given `java.math.BigDecimal` value.
  `void`
  BaseRowSet.`setBigDecimal(String parameterName, BigDecimal x)`
  Sets the designated parameter to the given `java.math.BigDecimal` value.

- ## Uses of BigDecimal in javax.sql.rowset.serial

  Methods in javax.sql.rowset.serial that return BigDecimal
  Modifier and Type
  Method
  Description
  `BigDecimal`
  SQLInputImpl.`readBigDecimal()`
  Retrieves the next attribute in this `SQLInputImpl` object as a `java.math.BigDecimal`.
  Methods in javax.sql.rowset.serial with parameters of type BigDecimal
  Modifier and Type
  Method
  Description
  `void`
  SQLOutputImpl.`writeBigDecimal(BigDecimal x)`
  Writes a `java.math.BigDecimal` object in the Java programming language to this `SQLOutputImpl` object.

- ## Uses of BigDecimal in javax.xml.datatype

  Methods in javax.xml.datatype that return BigDecimal
  Modifier and Type
  Method
  Description
  `abstract BigDecimal`
  XMLGregorianCalendar.`getFractionalSecond()`
  Returns fractional seconds.
  Methods in javax.xml.datatype with parameters of type BigDecimal
  Modifier and Type
  Method
  Description
  `abstract Duration`
  Duration.`multiply(BigDecimal factor)`
  Computes a new duration whose value is `factor` times longer than the value of this duration.
  `abstract Duration`
  DatatypeFactory.`newDuration(boolean isPositive, BigInteger years, BigInteger months, BigInteger days, BigInteger hours, BigInteger minutes, BigDecimal seconds)`
  Obtain a new instance of a `Duration` specifying the `Duration` as isPositive, years, months, days, hours, minutes, seconds.
  `abstract XMLGregorianCalendar`
  DatatypeFactory.`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.
  `XMLGregorianCalendar`
  DatatypeFactory.`newXMLGregorianCalendarTime(int hours, int minutes, int seconds, BigDecimal fractionalSecond, int timezone)`
  Create a Java instance of XML Schema builtin datatype time.
  `abstract void`
  XMLGregorianCalendar.`setFractionalSecond(BigDecimal fractional)`
  Set fractional seconds.
  `void`
  XMLGregorianCalendar.`setTime(int hour, int minute, int second, BigDecimal fractional)`
  Set time as one unit, including the optional infinite precision fractional seconds.

- ## Uses of BigDecimal in jdk.incubator.vector

  Methods in jdk.incubator.vector with parameters of type BigDecimal
  Modifier and Type
  Method
  Description
  `static Float16`
  Float16.`valueOf(BigDecimal v)`
  Returns a `Float16` value rounded from the `BigDecimal` argument using the round to nearest rounding policy.