The actual result is 37.1465555388 whose scale must be 10 for it to be exact.

What the JavaDoc says is that the preferred scale is the difference meaning that if the result didn't actually need to be 10, then it would try to make it 8. For example if you would have divided by 2, whose scale is also 0, the result would have been 18573277.76940000 (scale 8).

EDIT: small addition - you can force the division to a certain scale by using the overloaded divide methods:

  • divide(BigDecimal, RoundingMode) that will give a BigDecimal with scale of this and value rounded using the specified rounding method if the result would actually need more decimals to be exact.

  • divide(BigDecimal, scale, RoundingMode) that will give a BigDecimal with specified scale, and value rounded by specified method if needed.

This might be useful if you're dividing by a number you know can cause repeating decimals, like 3 (1/3 = 0.333333...) since, if that happens, the simple divide will throw an exception. Bounding it to a maximum number of decimals will help you avoid the exception but will make your computations less precise.

Answer from Andrei Fierbinteanu on Stack Overflow
🌐
Tutorialspoint
tutorialspoint.com › home › java/math › bigdecimal divide with rounding modes and scale
BigDecimal Division in Java: Rounding Modes & Scale
September 1, 2008 - public BigDecimal divide(BigDecimal divisor, int scale, RoundingMode roundingMode) divisor − Value by which this BigDecimal is to be divided.
🌐
Medium
medium.com › @AlexanderObregon › javas-bigdecimal-divide-method-explained-204688fe717a
Java’s BigDecimal.divide() Method Explained | Medium
January 13, 2025 - The divide() method allows you to divide one BigDecimal value by another. Depending on the specific version of the method you use, it provides control over factors like rounding behavior and decimal places (scale).
🌐
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 roundingMode is UNNECESSARY and this.scale() is insufficient to represent the result of the division exactly or Divisor is 0. 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 = "2453648454542"; String
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.math.bigdecimal.divide
BigDecimal.Divide Method (Java.Math) | Microsoft Learn
Java documentation for java.math.BigDecimal.divide(java.math.BigDecimal, java.math.RoundingMode). 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().
🌐
Oracle
docs.oracle.com › javase › 7 › docs › api › java › math › BigDecimal.html
BigDecimal (Java Platform SE 7 )
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.
🌐
Tutorialspoint
tutorialspoint.com › java › math › bigdecimal_divide_introundingmode_scale.htm
Java.math.BigDecimal.divide() Method
ArithmeticException − If divisor == 0, or roundingMode == ROUND_UNNECESSARY and this.scale() is insufficient to represent the result of the division exactly. IllegalArgumentException − If roundingMode does not represent a valid rounding mode. The following example shows the usage of math.BigDecimal.divide() method. package com.tutorialspoint; import java.math.*; 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 4 scale // 1 specifies BigDecimal.ROUND_DOWN bg3 = bg1.divide(bg2, 4, 1); String str = "Division result is " +bg3; // print bg3 value System.out.println( str ); } }
🌐
Mpg
resources.mpi-inf.mpg.de › d5 › teaching › ss05 › is05 › javadoc › java › math › BigDecimal.html
BigDecimal
BigDecimal provides operations for basic arithmetic, scale manipulation, comparison, hashing, and format conversion. The BigDecimal class gives its user complete control over rounding behavior, forcing the user to explicitly specify a rounding behavior for operations capable of discarding precision (divide(BigDecimal, int), divide(BigDecimal, int, int), and setScale(int, int)).
🌐
Tabnine
tabnine.com › home page › code › java › java.math.bigdecimal
java.math.BigDecimal.divide java code examples | Tabnine
private BigDecimal toSeconds(Long nanoSeconds) { return BigDecimal.valueOf(nanoSeconds).divide(NANOS_PER_SECOND); } ... @Override public List<MutablePair<String, String>> getIntervals(String lowerBound, String upperBound, int numPartitions, TypeInfo typeInfo) { List<MutablePair<String, String>> intervals = new ArrayList<>(); DecimalTypeInfo decimalTypeInfo = (DecimalTypeInfo)typeInfo; int scale = decimalTypeInfo.getScale(); BigDecimal decimalLower = new BigDecimal(lowerBound); BigDecimal decimalUpper = new BigDecimal(upperBound); BigDecimal decimalInterval = (decimalUpper.subtract(decimalLower
Find elsewhere
🌐
RoseIndia
roseindia.net › java › java-bigdecimal › bigDecimal-divide-int.shtml
Java BigDecimal divide examples
bigdecimal_objectName = bigdecimal_objectDividendName.bigdecimal.divide(bigdecimal_objectDivisorName, int scale, int roundingMode); Java_BigDecimal_divide_int_scale_int_roundingMode.java
🌐
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 - 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.
🌐
Java
download.java.net › java › early_access › panama › docs › api › java.base › java › math › class-use › BigDecimal.html
Uses of Class java.math.BigDecimal (Java SE 19 & JDK 19 [build 1])
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.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › math › BigDecimal.html
BigDecimal (Java Platform SE 8 )
October 20, 2025 - 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.
🌐
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 › en › java › javase › 22 › docs › api › java.base › java › math › BigDecimal.html
BigDecimal (Java SE 22 & JDK 22)
July 16, 2024 - 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.
🌐
Oracle
docs.oracle.com › javase › 10 › docs › api › java › math › BigDecimal.html
BigDecimal (Java SE 10 & JDK 10 )
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.
🌐
GitHub
github.com › tc39 › proposal-decimal › issues › 13
BigDecimal with division and other operations which need to round · Issue #13 · tc39/proposal-decimal
November 13, 2019 - Java-like: Require that the user provide the precision and/or rounding mode as a parameter when performing division · Ruby-like: Just choose an arbitrary amount of extra decimal places to use for the division result · The implicit third option is to avoid division, and instead have a div/mod operation, or a "partition" operation (to split a BigDecimal into an integer number of buckets as equally as possible, at the precision of the BigDecimal)
Published   Nov 13, 2019
🌐
Oracle
docs.oracle.com › en › java › javase › 21 › docs › api › java.base › java › math › BigDecimal.html
BigDecimal (Java SE 21 & JDK 21)
January 20, 2026 - 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.