As specified in javadoc, a BigDecimal is defined by an integer value and a scale.

The value of the number represented by the BigDecimal is therefore (unscaledValue × 10^(-scale)).

So BigDecimal("1761e+5") has scale -5 and BigDecimal(176100000) has scale 0.

The division of the two BigDecimal is done using the -5 and 0 scales respectively because the scales are not specified when dividing. The divide documentation explains why the results are different.

divide

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

Parameters:

divisor - value by which this BigDecimal is to be divided.

Returns:

this / divisor

Throws:

ArithmeticException — if the exact quotient does not have a terminating decimal expansion

Since:

1.5

If you specify a scale when dividing, e.g. dividendo.divide(BigDecimal.valueOf(1000), 0, RoundingMode.HALF_UP) you will get the same result.

Answer from dcernahoschi on Stack Overflow
🌐
Stack Overflow
stackoverflow.com › questions › 67556279 › unable-to-perform-divide-operation-in-bigdecimal-java-without-rounding-off
Unable to perform divide operation in BigDecimal Java without rounding off - Stack Overflow
Because you have set it to 2, it will round it down to 2 decimals (hence you get 0.05). You could therefore just increase the scale of your division operation: ... Sign up to request clarification or add additional context in comments. ... Save this answer. ... Show activity on this post. The simplest way would be to rearrange the formula. You can change 850 * (a / b) to (850 * a) / b. (Do the multiplication first followed by the division) CopyBigDecimal.divide(BigDecimal.multiply(a,1,RoundingMode.HALF_UP),2,RoundingMode.HALF_UP);
🌐
Medium
medium.com › @AlexanderObregon › javas-bigdecimal-divide-method-explained-204688fe717a
Java’s BigDecimal.divide() Method Explained | Medium
January 13, 2025 - The BigDecimal.divide() method in Java is designed to handle division operations with precision, particularly useful for applications requiring exact decimal calculations. It belongs to the BigDecimal class in the java.math package and is commonly used in scenarios where floating-point arithmetic is inadequate due to potential rounding issues.
🌐
GeeksforGeeks
geeksforgeeks.org › java › bigdecimal-divide-method-in-java-with-examples
BigDecimal divide() Method in Java with Examples - GeeksforGeeks
July 12, 2025 - Exception: The method throws Arithmetic Exception if the result is inexact but the rounding mode is UNNECESSARY or mc.precision == 0 and the quotient has a non-terminating decimal expansion. Below programs is used to illustrate the divide() method of BigDecimal. ... // Java program to demonstrate // divide() method of BigDecimal import java.math.*; public class GFG { public static void main(String[] args) { // BigDecimal object to store the result BigDecimal res; // For user input // Use Scanner or BufferedReader // Two objects of String created // Holds the values String input1 = "24536482";
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › math › BigDecimal.html
BigDecimal (Java Platform SE 8 )
July 21, 2026 - ArithmeticException - if the rounding mode is UNNECESSARY and the BigDecimal operation would require rounding. ... 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.
🌐
Coderanch
coderanch.com › t › 450954 › java › avoid-rounding-BigDecimal-division
How to avoid rounding while BigDecimal division (Java in General forum at Coderanch)
June 23, 2009 - So you must round somewhere for BigDecimal for any number not a multiple of 2 and 5 only. 2048 is a multiple of 2 only, but 2047 isn't. so you must round. Choose a larger precision for your rounding. ... Campbell Ritchie wrote:Unless you divide by a number whose prime factors only include 2 ...
Top answer
1 of 7
26

As specified in javadoc, a BigDecimal is defined by an integer value and a scale.

The value of the number represented by the BigDecimal is therefore (unscaledValue × 10^(-scale)).

So BigDecimal("1761e+5") has scale -5 and BigDecimal(176100000) has scale 0.

The division of the two BigDecimal is done using the -5 and 0 scales respectively because the scales are not specified when dividing. The divide documentation explains why the results are different.

divide

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

Parameters:

divisor - value by which this BigDecimal is to be divided.

Returns:

this / divisor

Throws:

ArithmeticException — if the exact quotient does not have a terminating decimal expansion

Since:

1.5

If you specify a scale when dividing, e.g. dividendo.divide(BigDecimal.valueOf(1000), 0, RoundingMode.HALF_UP) you will get the same result.

2 of 7
7

The expressions new BigDecimal("176100000") and new BigDecimal("1761e+5") are not equal. BigDecimal keeps track of both value, and precision.

BigDecimal("176100000") has 9 digits of precision and is represented internally as the BigInteger("176100000"), multiplied by 1. BigDecimal("1761e+5") has 4 digits of precision and is represented internally as the BigInteger("1761"), multiplied by 100000.

When you a divide a BigDecimal by a value, the result respects the digits of precision, resulting in different outputs for seemingly equal values.

🌐
Tutorialspoint
tutorialspoint.com › java › math › bigdecimal_divide_rdroundingmode_scale.htm
Java.math.BigDecimal.divide() Method
ArithmeticException − If divisor is zero, roundingMode == RoundingMode.UNNECESSARY and the specified scale is insufficient to represent the result of the division exactly · The following example shows the usage of math.BigDecimal.divide() method. package com.tutorialspoint; import java.math.*; import java.lang.*; public class BigDecimalDemo { public static void main(String[] args) { // create 3 BigDecimal objects BigDecimal bg1, bg2, bg3; bg1 = new BigDecimal("16"); bg2 = new BigDecimal("3"); // divide bg1 with bg2 with 3 scale bg3 = bg1.divide(bg2, 3, RoundingMode.CEILING); String str = "Division result is " +bg3; // print bg3 value System.out.println( str ); } }
Find elsewhere
🌐
Stack Overflow
stackoverflow.com › questions › 56503428 › bigdecimal-divide-no-rounding
java - BigDecimal divide no rounding - Stack Overflow
June 8, 2019 - BigDecimal a= new BigDecimal("99999999999.999999"); BigDecimal b= new BigDecimal(0); b = a.setScale(0, BigDecimal.ROUND_UP); // 100000000000 b = a.setScale(0, BigDecimal.ROUND_CEILING); // 100000000000 b = a.setScale(0, BigDecimal.ROUND_DOWN); // 99999999999 b = a.setScale(0, BigDecimal.ROUND_FLOOR); // 99999999999 b = a.setScale(0, BigDecimal.ROUND_HALF_DOWN); // 100000000000 b = a.setScale(0, BigDecimal.ROUND_HALF_EVEN); // 100000000000 b = a.setScale(0, BigDecimal.ROUND_HALF_UP); // 100000000000
🌐
wikiHow
wikihow.tech › computers and electronics › software › programming › java › 3 ways to divide in java with decimals - wikihow tech
3 Ways to Divide in Java with Decimals - wikiHow Tech
April 17, 2025 - This wikiHow article will show you three ways to do decimal numbers in Java. If you want to divide two integers (non-decimal) and get a non-rounded answer, cast one of the operands to a double.
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.math.bigdecimal.divide
BigDecimal.Divide Method (Java.Math) | Microsoft Learn
[<Android.Runtime.Register("divide", "(Ljava/math/BigDecimal;Ljava/math/MathContext;)Ljava/math/BigDecimal;", "GetDivide_Ljava_math_BigDecimal_Ljava_math_MathContext_Handler")>] abstract member Divide : Java.Math.BigDecimal * Java.Math.MathContext -> Java.Math.BigDecimal override this.Divide : Java.Math.BigDecimal * Java.Math.MathContext -> Java.Math.BigDecimal ... Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License. Returns a BigDecimal whose value is (this / divisor), and whose scale is this.scale(). [Android.Runtime.Register("divide", "(Ljava/math/BigDecimal;Ljava/math/RoundingMode;)Ljava/math/BigDecimal;", "GetDivide_Ljava_math_BigDecimal_Ljava_math_RoundingMode_Handler")] public virtual Java.Math.BigDecimal?
🌐
Oracle
docs.oracle.com › javase › 9 › docs › api › java › math › BigDecimal.html
BigDecimal (Java SE 9 & JDK 9 )
ArithmeticException - if the rounding mode is UNNECESSARY and the BigDecimal operation would require rounding. ... 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.
🌐
Schneide Blog
schneide.blog › home › calculation with infinite decimal expansion in java
Calculation with infinite decimal expansion in Java – Schneide Blog
November 20, 2025 - When dividing decimal numbers in Java, some values—like 1 divided by 3—result in an infinite decimal expansion. In this blog post, I’ll show how such a calculation behaves using BigDecimal and BigFraction. BigDecimal Since this cannot be represented exactly in memory, performing such a division with BigDecimal without specifying a rounding mode leads to an…
🌐
Medium
medium.com › @skywalkerhunter › fix-divide-java-math-bigdecimal-int-in-java-math-bigdecimal-has-been-deprecated-and-why-22fe83b07e9
Fix — divide(java.math.BigDecimal,int) in ...
July 18, 2020 - divide(total, BigDecimal.ROUND_HALF_UP) Press enter or click to view image in full size · A real example. Step #4 — How about the setScale? Warning:(47, 146) java: setScale(int,int) in java.math.BigDecimal has been deprecated · Same trick, search for: BigDecimal.ROUND_HALF_UP ·
🌐
Java2Blog
java2blog.com › home › core java › bigdecimal › bigdecimal divide
BigDecimal divide - Java2Blog
January 11, 2021 - In this tutorial we will see about BigDecimal‘s divide method. BigDecimal’s divide method is used to divide one BigDecimal by another. You can specify scale and rounding mode to get the output according to your need.
🌐
Oracle
docs.oracle.com › javase › 7 › docs › api › java › math › BigDecimal.html
BigDecimal (Java Platform SE 7 )
ArithmeticException - if the rounding mode is UNNECESSARY and the BigDecimal operation would require rounding. ... 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.
🌐
Qlik Community
community.qlik.com › t5 › Talend-Studio › Tmap-BigDecimal-Divide-operation › td-p › 2334948
Solved: Tmap BigDecimal Divide operation - Qlik Community - 2334948
May 27, 2019 - The new divide(BigDecimal, RoundingMode) method should be used in preference to this legacy method. Parameters: divisor - value by which this BigDecimal is to be divided. ... Works for me! ... Form Java API, second parameter is rounding mode, not scale, scale is same a "this" (0, if null for your example).