A BigDecimal is an exact way of representing numbers. A Double has a certain precision. Working with doubles of various magnitudes (say d1=1000.0 and d2=0.001) could result in the 0.001 being dropped altogether when summing as the difference in magnitude is so large. With BigDecimal this would not happen.

The disadvantage of BigDecimal is that it's slower, and it's a bit more difficult to program algorithms that way (due to + - * and / not being overloaded).

If you are dealing with money, or precision is a must, use BigDecimal. Otherwise Doubles tend to be good enough.

I do recommend reading the javadoc of BigDecimal as they do explain things better than I do here :)

Answer from extraneon on Stack Overflow
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › math › BigDecimal.html
BigDecimal (Java Platform SE 8 )
October 20, 2025 - Java™ Platform Standard Ed. 8 ... 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.
🌐
GeeksforGeeks
geeksforgeeks.org › java › bigdecimal-class-java
BigDecimal Class in Java - GeeksforGeeks
March 8, 2024 - Java Collection · Last Updated : 8 Mar, 2024 · The BigDecimal class provides operations on double numbers for arithmetic, scale handling, rounding, comparison, format conversion and hashing.
Discussions

java - BigDecimal, precision and scale - Stack Overflow
I'm using BigDecimal for my numbers in my application, for example, with JPA. I did a bit of researching about the terms 'precision' and 'scale' but I don't understand what are they exactly. Can a... More on stackoverflow.com
🌐 stackoverflow.com
Double vs BigDecimal in financial programming

Use long or big decimal. Performance problems will most probably arise elsewhere before you factor a big decimal as the culprit

More on reddit.com
🌐 r/java
105
44
July 17, 2016
IGN-11140 toDict() and java.math.BigDecimal
So this just started happening.... When I call the .toDict() method on Memory Tag, of value type "document" all of the Integers and Floats are cast as 0 More on forum.inductiveautomation.com
🌐 forum.inductiveautomation.com
0
October 12, 2023
Can BigDecimal stpre irrational numbers?
Accurately, no. That's why they're irrational. For a given decimal places, sure, that is the purpose of BigDecimal. More on reddit.com
🌐 r/java
5
3
September 8, 2018
🌐
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 - The results of this constructor can be somewhat unpredictable. One might assume that writing new BigDecimal(0.1) in Java creates a BigDecimal which is exactly equal to 0.1 (an unscaled value of 1, with a scale of 1), but it is actually equal to 0.1000000000000000055511151231257827021181583404541015625.
🌐
Baeldung
baeldung.com › home › java › java numbers › bigdecimal and biginteger in java
BigDecimal and BigInteger in Java | Baeldung
December 16, 2024 - BigDecimal is a special class in Java used to represent numbers with a high degree of precision.
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.

Find elsewhere
🌐
Android Developers
developer.android.com › api reference › bigdecimal
BigDecimal | API reference | Android Developers
Skip to main content · English · Deutsch · Español – América Latina · Français · Indonesia · Polski · Português – Brasil · Tiếng Việt · 中文 – 简体
🌐
CodeGym
codegym.cc › java blog › java numbers › bigdecimal in java
BigDecimal in Java
January 15, 2025 - What do we need to come up with if our Very Large Number requires 100 bits? Fortunately, we don't need to invent anything. For cases such as this, Java has two special classes: BigInteger (for integers) and BigDecimal (for floating-point numbers).
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.math.bigdecimal.-ctor
BigDecimal Constructor (Java.Math) | Microsoft Learn
[Android.Runtime.Register(".ctor", "([CII)V", "")] public BigDecimal(char[]? in, int offset, int len); [<Android.Runtime.Register(".ctor", "([CII)V", "")>] new Java.Math.BigDecimal : char[] * int * int -> Java.Math.BigDecimal
🌐
Piotr Horzycki
peterdev.pl › all-you-need-to-know-about-javas-bigdecimal
All you need to know about Java’s BigDecimal
February 11, 2021 - A guide to Java BigDecimal class. Examples of monetary calculations and formatting decimal numbers for different languages.
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.math.bigdecimal
BigDecimal Class (Java.Math) | Microsoft Learn
Square brackets are used to represent the particular BigInteger and scale pair defining a BigDecimal value; for example [19, 2] is the BigDecimal numerically equal to 0.19 having a scale of 2. All methods and constructors for this class throw NullPointerException when passed a null object reference for any input parameter. Added in 1.1. Java documentation for java.math.BigDecimal.
🌐
Reddit
reddit.com › r/java › double vs bigdecimal in financial programming
r/java on Reddit: Double vs BigDecimal in financial programming
July 17, 2016 -

Everyone says that BigDecimal should be used when dealing with money but it’s much slower and takes more memory than double. I would think this would be especially important in high frequency low-latency applications like trading. Do people actually use BigDecimal in such systems or do they use doubles with some kind of workaround to handle the precision issue?

Edit: I do have experience working on trading and risk systems and I see doubles used much more often than BigDecimal so I was curious to see if this is more common in actual practice. Most of the systems I worked on only need precision to the penny so I wonder if that’s the reason?

Also, BigDecimal is a pain to use and code written with it look much uglier than plain doubles.

🌐
Coderanch
coderanch.com › t › 648068 › java › BigDecimal-Usefulness-Overkill
BigDecimal: Usefulness vs Overkill [Solved] (Beginning Java forum at Coderanch)
March 31, 2015 - A double is 64 bits while a BigDecimal is an object that has quite a number of internal fields. See http://stackoverflow.com/questions/2501176/java-bigdecimal-memory-usage Yes, but to me it's still a discovery because it was the first time for me to actually measure that memory usage.
🌐
GitHub
github.com › openjdk-mirror › jdk7u-jdk › blob › master › src › share › classes › java › math › BigDecimal.java
jdk7u-jdk/src/share/classes/java/math/BigDecimal.java at master · openjdk-mirror/jdk7u-jdk
import static java.math.BigInteger.LONG_MASK; · /** * Immutable, arbitrary-precision signed decimal numbers. A · * {@code BigDecimal} consists of an arbitrary precision integer · * <i>unscaled value</i> and a 32-bit integer <i>scale</i>. ...
Author   openjdk-mirror
🌐
Medium
elvisciotti.medium.com › java-bigdecimal-in-javascript-9498fd4f2efe
Java BigDecimal in Javascript
August 10, 2024 - To use Java’s BigDecimal operations like multiply, and divide, the closest library I found is bignumber.js
🌐
Codementor
codementor.io › community › bigdecimal class in java
BigDecimal Class in Java | Codementor
June 23, 2024 - Are you planning to write a Java program that requires total control over the scaling of decimal numbers? BigDecimal is the class you need to deal with. In this tutorial, you will learn what a BigDecimal is.
🌐
Dummies
dummies.com › article › technology › programming-web-design › java › how-to-create-bigdecimal-objects-in-java-153270
How to Create BigDecimal Objects in Java | dummies
July 2, 2025 - Note: The BigDecimal class has no default constructor because you can’t have a BigDecimal object without a value. No items found. Doug Lowe is the information technology director at Blair, Church & Flynn Consulting Engineers, a civil engineering firm. He has written more than 50 For Dummies books on topics ranging from Java to electronics to PowerPoint.
🌐
Medium
medium.com › javarevisited › java-how-exactly-should-long-and-bigdecimal-be-used-can-you-distinguish-them-5c91c8bce18f
JAVA: How Exactly Should Long and BigDecimal Be Used? Can You Distinguish Them? | by Oliver Foster | Javarevisited | Medium
January 30, 2024 - The Long class, found in the java.lang package, provides a variety of methods for manipulating long integer values. Usage: It is used for handling large integer values where no fractional part is needed. Range: The range of Long is from -2^63 to 2^63-1. Performance: Compared to BigDecimal, Long typically offers faster performance as it is a wrapper class for a primitive type.
🌐
Inductive Automation
forum.inductiveautomation.com › ignition
toDict() and java.math.BigDecimal - Ignition
October 12, 2023 - So this just started happening.... When I call the .toDict() method on Memory Tag, of value type "document" all of the Integers and Floats are cast as <type 'java.math.BigDecimal'>. parsed = system.tag.readBlocking(["[d…