A BigDecimal is defined by two values: an arbitrary precision integer and a 32-bit integer scale. The value of the BigDecimal is defined to be unscaledValue * 10 ^ (-scale).

Precision:

The precision is the number of digits in the unscaled value. For instance, for the number 123.45, the precision returned is 5.

So, precision indicates the length of the arbitrary precision integer. Here are a few examples of numbers with the same scale, but different precision:

  • 12345 / 100000 = 0.12345 // scale = 5, precision = 5
  • 12340 / 100000 = 0.1234 // scale = 4, precision = 4
  • 1 / 100000 = 0.00001 // scale = 5, precision = 1

In the special case that the number is equal to zero (i.e. 0.000), the precision is always 1.

Scale:

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.

This means that the integer value of the ‘BigDecimal’ is multiplied by 10 ^ (-scale).

Here are a few examples of the same precision, with different scales:

  • 12345 with scale 5 = 0.12345
  • 12345 with scale 4 = 1.2345
  • …
  • 12345 with scale 0 = 12345
  • 12345 with scale -1 = 123450 †

BigDecimal.toString:

The toString method for a BigDecimal behaves differently based on the scale and precision. (Thanks to @RudyVelthuis for pointing this out.)

  • If scale == 0, the integer is just printed out, as-is.
  • If scale < 0, E-Notation is always used (e.g. 5 scale -1 produces "5E+1")
  • If scale >= 0 and precision - scale -1 >= -6 a plain decimal number is produced (e.g. 10000000 scale 1 produces "1000000.0")
  • Otherwise, E-notation is used, e.g. 10 scale 8 produces "1.0E-7" since precision - scale -1 equals unscaledValue * 10 ^ (-scale) is less than -6.

More examples:

  • 19/100 = 0.19 // integer=19, scale=2, precision=2
  • 1/1000 = 0.0001 // integer=1, scale = 4, precision = 1
Answer from Austin on Stack Overflow
Top answer
1 of 6
181

A BigDecimal is defined by two values: an arbitrary precision integer and a 32-bit integer scale. The value of the BigDecimal is defined to be unscaledValue * 10 ^ (-scale).

Precision:

The precision is the number of digits in the unscaled value. For instance, for the number 123.45, the precision returned is 5.

So, precision indicates the length of the arbitrary precision integer. Here are a few examples of numbers with the same scale, but different precision:

  • 12345 / 100000 = 0.12345 // scale = 5, precision = 5
  • 12340 / 100000 = 0.1234 // scale = 4, precision = 4
  • 1 / 100000 = 0.00001 // scale = 5, precision = 1

In the special case that the number is equal to zero (i.e. 0.000), the precision is always 1.

Scale:

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.

This means that the integer value of the ‘BigDecimal’ is multiplied by 10 ^ (-scale).

Here are a few examples of the same precision, with different scales:

  • 12345 with scale 5 = 0.12345
  • 12345 with scale 4 = 1.2345
  • …
  • 12345 with scale 0 = 12345
  • 12345 with scale -1 = 123450 †

BigDecimal.toString:

The toString method for a BigDecimal behaves differently based on the scale and precision. (Thanks to @RudyVelthuis for pointing this out.)

  • If scale == 0, the integer is just printed out, as-is.
  • If scale < 0, E-Notation is always used (e.g. 5 scale -1 produces "5E+1")
  • If scale >= 0 and precision - scale -1 >= -6 a plain decimal number is produced (e.g. 10000000 scale 1 produces "1000000.0")
  • Otherwise, E-notation is used, e.g. 10 scale 8 produces "1.0E-7" since precision - scale -1 equals unscaledValue * 10 ^ (-scale) is less than -6.

More examples:

  • 19/100 = 0.19 // integer=19, scale=2, precision=2
  • 1/1000 = 0.0001 // integer=1, scale = 4, precision = 1
2 of 6
98
  • Precision: Total number of significant digits

  • Scale: Number of digits to the right of the decimal point

See BigDecimal class documentation for details.

🌐
Piotr Horzycki
peterdev.pl › all-you-need-to-know-about-javas-bigdecimal
All you need to know about Java’s BigDecimal | Piotr Horzycki - Java and PHP developer’s blog
February 11, 2021 - BigDecimal uses two parameters to define the maximum number of digits it can hold and how many digits are behind the decimal point. The first one is called precision, and the other one is called scale.
🌐
GeeksforGeeks
geeksforgeeks.org › java › bigdecimal-scale-method-in-java
BigDecimal scale() Method in Java - GeeksforGeeks
December 4, 2018 - The java.math.BigDecimal.scale() is an inbuilt method in java that returns the scale of this BigDecimal.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › math › BigDecimal.html
BigDecimal (Java Platform SE 8 )
July 21, 2026 - Scaling/rounding operations (setScale and round) return a BigDecimal whose value is approximately (or exactly) equal to that of the operand, but whose scale or precision is the specified value; that is, they increase or decrease the precision of the stored number with minimal effect on its value.
🌐
im seoin
inseo24.github.io › java › bigDecimal
BigDecimal 클래스를 공부해보자!(precision, scale …) | im seoin
November 30, 2022 - BigDecimal은 유효한 숫자의 역할을 하는 unscaledValue와 32-bit의 scale로 이뤄져 있다. 실제 이 값들이 나타내는 BigDecimal은 unscaledValue * (10^(-scale)) 이다.
🌐
Baeldung
baeldung.com › home › java › java numbers › bigdecimal and biginteger in java
BigDecimal and BigInteger in Java | Baeldung
December 16, 2024 - Control over scale and rounding is required: BigDecimal allows us to specify how many digits to keep after the decimal point and how to round numbers when necessary
🌐
Tutorialspoint
tutorialspoint.com › java › math › bigdecimal_scale.htm
Java.math.BigDecimal.scale() Method
The java.math.BigDecimal.scale() 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
🌐
Codementor
codementor.io › community › bigdecimal class in java
BigDecimal Class in Java | Codementor
June 23, 2024 - According to its Javadoc, a BigDecimal represents an immutable, arbitrary-precision decimal number. A BigDecimal consists of an arbitrary-precision integer unscaled value and a 32-bit integer scale.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › java › bigdecimal-setscale-method-in-java-with-examples
BigDecimal setScale() method in Java with Examples - GeeksforGeeks
July 11, 2025 - This method is used to calculate 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 then unscaled value must be divided (rather than multiplied).
🌐
Tutorialspoint
tutorialspoint.com › java › math › bigdecimal_setscale_rm_roundingmode.htm
Java.math.BigDecimal.setScale() Method
The java.math.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 ...
🌐
Oracle
docs.oracle.com › javase › 7 › docs › api › java › math › BigDecimal.html
BigDecimal (Java Platform SE 7 )
Scaling/rounding operations (setScale and round) return a BigDecimal whose value is approximately (or exactly) equal to that of the operand, but whose scale or precision is the specified value; that is, they increase or decrease the precision of the stored number with minimal effect on its value.
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.math.bigdecimal.scale
BigDecimal.Scale Method (Java.Math) | Microsoft Learn
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.
🌐
Reddit
reddit.com › r/javahelp › bigdecimal scale and rounding confusion
r/javahelp on Reddit: BigDecimal scale and rounding confusion
July 20, 2022 -

BigDecimal(55.325).setScale(2,RoundingMode.HALF_DOWN) //55.33 BigDecimal(55.355).setScale(2,RoundingMode.HALF_DOWN) //55.35

I would expect the first result to be 55.32. As per the second example it is rounded down to 55.35

🌐
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › math › BigDecimal.html
BigDecimal (Java SE 17 & JDK 17)
April 21, 2026 - Scaling/rounding operations (setScale and round) return a BigDecimal whose value is approximately (or exactly) equal to that of the operand, but whose scale or precision is the specified value; that is, they increase or decrease the precision of the stored number with minimal effect on its value.
🌐
javathinking
javathinking.com › blog › bigdecimal-precision-and-scale
BigDecimal Precision and Scale Explained: What They Mean in Java (With JPA @Column Example) — javathinking.com
Division is the most complex, as it can produce non-terminating decimals (e.g., 1 ÷ 3 = 0.333...). By default, BigDecimal throws an ArithmeticException for non-terminating division. To avoid this, explicitly specify the result scale and rounding mode.
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.math.bigdecimal
BigDecimal Class (Java.Math) | Microsoft Learn
Scaling/rounding operations (#setScale setScale and #round round) return a BigDecimal whose value is approximately (or exactly) equal to that of the operand, but whose scale or precision is the specified value; that is, they increase or decrease ...
🌐
GeeksforGeeks
geeksforgeeks.org › java › bigdecimal-class-java
BigDecimal Class in Java - GeeksforGeeks
March 8, 2024 - A BigDecimal consists of a random precision integer unscaled value and a 32-bit integer scale. If greater than or equal to zero, the scale is the number of digits to the right of the decimal point.
🌐
Medium
medium.com › javarevisited › mastering-java-bigdecimal-precision-math-made-simple-dde4007b7359
Mastering Java BigDecimal: Precision Math Made Simple. | by sajith dilshan | Javarevisited | Medium
June 18, 2025 - Use String Constructors: As I mentioned earlier, new BigDecimal("0.1") is way safer than new BigDecimal(0.1). It avoids floating-point errors from the get-go. Always Set Scale and Rounding for Division: Division without a scale is asking for trouble. Pick a reasonable scale (e.g., 2 for money, 10 for scientific calculations) and a rounding mode that fits your use case.
🌐
IncludeHelp
includehelp.com › java › bigdecimal-scale-method-with-example.aspx
Java BigDecimal scale() Method with Example
Case 1: The scale is the number of digits represented to the right side of decimal when this BigDecimal is 0 or +ve.