You haven't specified a scale for the result. Please try this

2019 Edit: Updated answer for JDK 13. Cause hopefully you've migrated off of JDK 1.5 by now.

import java.math.BigDecimal;
import java.math.RoundingMode;

public class Main {

    public static void main(String[] args) {
        BigDecimal a = new BigDecimal("1");
        BigDecimal b = new BigDecimal("3");
        BigDecimal c = a.divide(b, 2, RoundingMode.HALF_UP);
        System.out.println(a + "/" + b + " = " + c);
    }

}

Please read JDK 13 documentation.

Old answer for JDK 1.5 :

import java.math.*; 

    public class x
    {
      public static void main(String[] args)
      {
        BigDecimal a = new BigDecimal("1");
        BigDecimal b = new BigDecimal("3");
        BigDecimal c = a.divide(b,2, BigDecimal.ROUND_HALF_UP);
        System.out.println(a+"/"+b+" = "+c);
      }
    }

this will give the result as 0.33. Please read the API

Answer from Rohan Grover on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › java › bigdecimal-divide-method-in-java-with-examples
BigDecimal divide() Method in Java with Examples - GeeksforGeeks
July 12, 2025 - Return value: This method returns a BigDecimal which holds the result (this / divisor) and rounded as necessary. Exception: The method throws Arithmetic Exception if the result is inexact but the rounding mode is UNNECESSARY or mc.precision ...
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › math › BigDecimal.html
BigDecimal (Java Platform SE 8 )
October 20, 2025 - Returns a BigDecimal whose value is (this / divisor), and whose scale is as specified. If rounding must be performed to generate a result with the specified scale, the specified rounding mode is applied. The new divide(BigDecimal, int, RoundingMode) method should be used in preference to this ...
🌐
Tutorialspoint
tutorialspoint.com › home › java/math › bigdecimal divide with rounding modes and scale
BigDecimal Divide with Rounding Modes and Scale
September 1, 2008 - divisor − Value by which this BigDecimal is to be divided. scale − Scale of the BigDecimal quotient to be returned. ... This method returns a BigDecimal object whose value is this / divisor rounded as specified to given scale
🌐
Medium
medium.com › @AlexanderObregon › javas-bigdecimal-divide-method-explained-204688fe717a
Java’s BigDecimal.divide() Method Explained | Medium
January 13, 2025 - Division with Scale and Rounding Mode: For more control, the divide() method allows specifying both the scale (number of decimal places) and a rounding mode. This is particularly useful in applications where the precision of the result must ...
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.math.bigdecimal.divide
BigDecimal.Divide Method (Java.Math) | Microsoft Learn
Portions of this page are modifications ... Creative Commons 2.5 Attribution License. Returns a BigDecimal whose value is (this / divisor), with rounding according to the context settings....
🌐
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
🌐
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 - int scale, RoundingMode roundingMode) Returns a BigDecimal whose value is (this / divisor), and whose scale is as specified. If rounding must be performed to generate a result with the specified scale, the specified rounding mode is applied.
Find elsewhere
🌐
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 ... value must be divided (rather than multiplied), and the value may be changed; in this case, the specified rounding mode is applied to the division....
🌐
JetBrains
jetbrains.com › help › inspectopedia › BigDecimalMethodWithoutRoundingCalled.html
Call to 'BigDecimal' method without a rounding mode argument | Inspectopedia Documentation
December 3, 2025 - Such calls can lead to an ArithmeticException when the exact value cannot be represented in the result (for example, because it has a non-terminating decimal expansion). Specifying a rounding mode prevents the ArithmeticException. Example: ...
🌐
Tutorialspoint
tutorialspoint.com › java › math › bigdecimal_divide_rdroundingmode.htm
Java.math.BigDecimal.divide() Method
The java.math.BigDecimal.divide(BigDecimal divisor, RoundingMode roundingMode) returns a BigDecimal whose value is (this / divisor), and whose scale is this.scale(). If rounding must be performed to generate a result with the given scale, the specified rounding mode is applied.
🌐
Oracle
docs.oracle.com › javase › 7 › docs › api › java › math › BigDecimal.html
BigDecimal (Java Platform SE 7 )
Returns a BigDecimal whose value is (this / divisor), and whose scale is as specified. If rounding must be performed to generate a result with the specified scale, the specified rounding mode is applied. The new divide(BigDecimal, int, RoundingMode) method should be used in preference to this ...
🌐
Tabnine
tabnine.com › home page › code › java › java.math.bigdecimal
java.math.BigDecimal.divide java code examples | Tabnine
/** * 人民币金额单位转换,分转换成元,取两位小数 例如:150 => 1.5 */ public static BigDecimal fen2yuan(BigDecimal num) { return num.divide(new BigDecimal(100), 2, RoundingMode.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.
🌐
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, RoundingMode.HALF_UP) Instead of: 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 ·
🌐
Qlik Community
community.qlik.com › t5 › Design-and-Development › Tmap-BigDecimal-Divide-operation › td-p › 2334948
Tmap BigDecimal Divide operation
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. roundingMode - rounding mode to apply.
🌐
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 and 5, every division will recur, and go on to infinity.
🌐
NewbeDEV
newbedev.com › java-s-bigdecimal-divide-and-rounding
Java's Bigdecimal.divide and rounding
If you specify a scale when dividing, e.g. dividendo.divide(BigDecimal.valueOf(1000), 0, RoundingMode.HALF_UP) you will get the same result.