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 .

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 .

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 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
🌐
Coderanch
coderanch.com › t › 406596 › java › BigDecimal-setScale
BigDecimal, setScale() and ROUND_HALF_UP... (Beginning Java forum at Coderanch)
Hi Jim, There's no such method called toPlainString() within the java.math.BigDecimal APIs. Regards, Jagan. ... Notice that the scale is the number of digits after the decimal point.
🌐
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.
🌐
Oracle
docs.oracle.com › javase › 7 › docs › api › java › math › BigDecimal.html
BigDecimal (Java Platform SE 7 )
Immutable, arbitrary-precision signed decimal numbers. A BigDecimal consists of an arbitrary precision integer unscaled value and a 32-bit integer 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 ...
Top answer
1 of 6
179

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 .

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 .

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

🌐
Tutorialspoint
tutorialspoint.com › home › java/math › bigdecimal scale in java
BigDecimal scale in Java
September 1, 2008 - Learn how to use BigDecimal scale in Java to manage precision and control decimal places effectively. Explore examples and best practices.
🌐
Tutorialspoint
tutorialspoint.com › home › java/math › bigdecimal setscale with roundingmode in java
BigDecimal setScale with RoundingMode in Java
September 1, 2008 - This method 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.
🌐
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-scale-method-in-java
BigDecimal scale() Method in Java - GeeksforGeeks
December 4, 2018 - // Java program to demonstrate the // scale() method import java.math.*; public class Gfg { public static void main(String[] args) { BigDecimal b1 = new BigDecimal("456.0"); BigDecimal b2 = new BigDecimal("-1.456"); // Assign the result of scale on // BigDecimal Objects b1, b2 to int objects i1, i2 int i1 = b1.scale(); int i2 = b2.scale(); // Print the values of i1, i2; System.out.println("The scale of " + b1 + " is " + i1); System.out.println("The scale of " + b2 + " is " + i2); } }
Find elsewhere
🌐
Piotr Horzycki
peterdev.pl › all-you-need-to-know-about-javas-bigdecimal
All you need to know about Java’s BigDecimal
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.
🌐
Baeldung
baeldung.com › home › java › java numbers › bigdecimal and biginteger in java
BigDecimal and BigInteger in Java | Baeldung
December 16, 2024 - It consists of two parts: Unscaled value: This is an integer that represents the number without any decimal point · Scale: This is a number that indicates how many digits are to the right of the decimal point
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › math › BigDecimal.html
BigDecimal (Java Platform SE 8 )
October 20, 2025 - Immutable, arbitrary-precision signed decimal numbers. A BigDecimal consists of an arbitrary precision integer unscaled value and a 32-bit integer 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 ...
🌐
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).
🌐
Mpg
resources.mpi-inf.mpg.de › d5 › teaching › ss05 › is05 › javadoc › java › math › BigDecimal.html
BigDecimal
Immutable, arbitrary-precision signed decimal numbers. A BigDecimal consists of an arbitrary precision integer unscaled value and a non-negative 32-bit integer scale, which represents the number of digits to the right of the decimal point. The number represented by the BigDecimal is ...
🌐
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › math › BigDecimal.html
BigDecimal (Java SE 17 & JDK 17)
January 20, 2026 - Immutable, arbitrary-precision signed decimal numbers. A BigDecimal consists of an arbitrary precision integer unscaled value and a 32-bit integer 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 ...
🌐
Oracle
docs.oracle.com › en › java › javase › 22 › docs › api › java.base › java › math › BigDecimal.html
BigDecimal (Java SE 22 & JDK 22)
July 16, 2024 - Immutable, arbitrary-precision signed decimal numbers. A BigDecimal consists of an arbitrary precision integer unscaled value and a 32-bit integer scale. If the scale is zero or positive, the scale is the number of digits to the right of the decimal point. If the scale is negative, the unscaled ...
🌐
Scala Programming Language
scala-lang.org › api › 2.12.6 › scala › math › BigDecimal.html
Scala Standard Library 2.12.6 - scala.math.BigDecimal
Returns a BigDecimal whose scale is the specified value, and whose value is numerically equal to this BigDecimal's.
🌐
Scala Programming Language
scala-lang.org › api › 3.0.0 › scala › math › BigDecimal.html
BigDecimal
BigDecimal represents decimal floating-point numbers of arbitrary precision. By default, the precision approximately matches that of IEEE 128-bit floating point numbers (34 decimal digits, HALF_EVEN rounding mode). Within the range of IEEE binary128 numbers, BigDecimal will agree with BigInt ...
🌐
University of Washington
courses.cs.washington.edu › courses › cse341 › 98au › java › jdk1.2beta4 › docs › api › java › math › BigDecimal.html
Class java.math.BigDecimal
The fraction consists of of a decimal ... fractional part. The scale of the resulting BigDecimal will be the number of digits to the right of the decimal point in the string, or 0 if the string contains no decimal point....
🌐
Coderanch
coderanch.com › t › 473245 › java › Reduce-scale-BigDecimal-required-represent
Reduce scale of BigDecimal to that required to represent exactly? (Java in General forum at Coderanch)
i believe this is the "setScale() method" with specifying the "ROUND_UNNECESSARY" rounding mode, the Java API for this: http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigDecimal.html For example, which outputs · original: 1.50000 result: 1.5 original: 10.00000 result: 10.0 but this isn't the "two significant digits" thing you have there, in that setScale() works to set the number of decimal places to be scaled to, (typically for currency quantities I would use 2 and ROUND_HALFEVEN) I guess if you wanted to show up to 1 decimal place, but no decimal places when the number is an integer (whole number), then we could run it through a decimal formatter which now outputs