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
🌐
Reddit
reddit.com › r/java › double vs bigdecimal in financial programming
r/java on Reddit: Double vs BigDecimal in financial programming
May 22, 2018 -

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.

🌐
Medium
solutionsarchitecture.medium.com › mastering-big-decimals-in-java-understanding-implementation-performance-and-alternatives-7e3a3a96efc6
Mastering Big Decimals in Java: Understanding Implementation, Performance, and Alternatives | by Rahul Krishnan | Medium
September 22, 2024 - In Java, BigDecimal is a class designed to handle arbitrary-precision decimal numbers. Unlike the primitive data types float and double, which have fixed precision, BigDecimal can represent numbers with any desired level of accuracy.
🌐
Frankel
blog.frankel.ch › bigdecimal-vs-double
double, BigDecimal, or Fixed-Point?
June 14, 2026 - Internally, a BigDecimal is an unscaled integer value plus a scale: ... This means that 19.99 is stored as exactly 19.99, not as the nearest binary approximation. Every arithmetic operation preserves decimal semantics, and you control the rounding ...
🌐
Baeldung
baeldung.com › home › java › java numbers › bigdecimal and biginteger in java
BigDecimal and BigInteger in Java | Baeldung
December 16, 2024 - BigDecimal represents an immutable arbitrary-precision signed decimal number.
🌐
Baeldung
baeldung.com › home › java › java numbers › java double vs. bigdecimal
Java Double vs. BigDecimal | Baeldung
January 8, 2024 - The BigDecimal class offers better precision than Double, as it can perform calculations with arbitrary-precision decimals, avoiding the rounding errors arising from Double’s binary representation.
🌐
Medium
medium.com › @reachansari › use-of-bigdecimal-instead-double-in-java-for-financial-systems-591440bdd5f4
Use of BigDecimal instead of double in Java for Financial systems | by Thameem Ansari | Medium
March 22, 2022 - But in financial or any other systems where each digit of decimal part are important, BigDecimal should be chosen over double/float.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › math › BigDecimal.html
BigDecimal (Java Platform SE 8 )
July 21, 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 ...
Find elsewhere
Top answer
1 of 4
17

From: http://www.javamex.com/tutorials/math/BigDecimal_BigInteger_performance.shtml

Note that a BigDecimal is essentially a wrapper around a BigInteger that "remembers where the decimal point is".

Because of the way we are used to dealing with numbers, as humans, we may have to "think a bit more" when calculating with non-integers by hand compared to integers (e.g. we may have learnt the 7 times table by heart to speed up certain calculations, but probably not the .7 times table). But to a computer implementation, it is essentially no more effort to manipulate non-integers than it is integers, and so on the whole, methods on BigDecimal tend to perform similarly to analogous methods on BigInteger.

2 of 4
4

I know the title of your question states "Performace of BigDecimal vs. BigInteger and BigDecimal" but one of your questions states "How about using only primitive data types and BigInteger or only BigInteger to make ". Well here is what I recommend:

If you need accuracy, precision and you have large numbers to work with such as huge financial data then it may be best to use BigDecimal and BigInteger instead of primitive types. Few other characteristics of BigDecimal and BigInteger are also:

  1. Both are from immutable objects.
  2. Both extend from Number class and implement comparable interface

Now back to your main question in terms of performance, there is not much of difference in terms of performance between the two. If you can present your information in BigDecimal just use that so you don't have to convert it over to BigInteger but again look at the program and see if it does make sense to only use BigDecimal all the time. The main difference between the BigInteger and BigDecimal is that BigInteger supports arbitrary-precision integers and BigDecimal is for arbitrary-precision fixed-point numbers.

Here are my sources and good luck :)

NY University

Colorado University

🌐
LinkedIn
linkedin.com › pulse › need-precision-why-you-should-use-javas-bigdecimal-janaka-wijerathne-vzoic
Need Precision? Why You Should Use Java’s BigDecimal and BigInteger Instead of Primitives
June 19, 2024 - `BigDecimal` is designed for precise decimal values, often used in financial calculations, while `BigInteger` handles very large integer values, crucial for cryptographic and large-scale numerical computations.
🌐
LinkedIn
linkedin.com › pulse › why-we-should-use-bigdecimal-instead-double-java-financial-ismail
Why we should use BigDecimal instead double in java for financial systems
May 17, 2022 - But in financial or any other systems where each digit of decimal part are important, BigDecimal should be chosen over double/float.
🌐
DEV Community
dev.to › luke_tong_d4f228249f32d86 › beyond-double-essential-bigdecimal-practices-for-accurate-financial-calculations-52m1
Beyond double: Essential BigDecimal Practices for Accurate Financial Calculations - DEV Community
May 28, 2025 - Why? Because the string “0.1” is an exact representation. BigDecimal uses concepts of precision (the total number of digits) and scale (the number of digits to the right of the decimal point).
🌐
Medium
serdaralkancode.medium.com › why-use-bigdecimal-instead-of-double-java-179e51cd1cbc
Why use BigDecimal instead of Double? (Java) | by Serdar ALKAN | Medium
October 1, 2024 - Immutable, arbitrary-precision signed decimal numbers. A BigDecimal consists of an arbitrary precision integer unscaled value and a 32-bit integer scale.
🌐
Quora
quora.com › What-is-the-difference-between-BigDecimal-vs-Double
What is the difference between BigDecimal vs Double? - Quora
Answer (1 of 6): Double is a wrapper for the Java native double type, a 64-bit floating point number. BigDecimal is arbitrary-precision arithmetic. It can represent numbers to as many bits of precision as you want to throw memory and time at. (Technically, it's limited to a 32 bit exponent, but ...
🌐
Medium
muratakkan.medium.com › bigdecimal-achieving-financial-accuracy-in-java-76140af086bc
BigDecimal: Achieving Financial Accuracy in Java | Medium
January 13, 2023 - The BigDecimal class, on the other hand, is a more suitable choice for financial and monetary calculations. It provides arbitrary-precision decimal arithmetic, meaning it can represent decimal values exactly without the inaccuracies that can ...
🌐
Medium
medium.com › @qingedaig › java-bigdecimal-vs-double-vs-float-012c7149e550
Java BigDecimal vs double vs float | by Alice Dai | Medium
October 15, 2024 - Precision Required: Use BigDecimal when you need high precision in calculations, especially with financial or monetary values where rounding errors can lead to significant issues. Exact Values: It’s ideal for scenarios where you need exact decimal representation, such as in currency calculations (e.g., banking applications).
🌐
Coderanch
coderanch.com › t › 492688 › java › java-math-BigDecimal-double-float
java.math.BigDecimal vs double or float datatypes (Beginning Java forum at Coderanch)
April 22, 2010 - So BigDecimal is able to represent very precise decimal values and you should typically use it when you need really accurate computations.