Tiger java.math.BigDecimal platform :win2000
divideToIntegralValue(divisorBD,mc)
for the following data point and MathContext
String dividend = "123456789000";
String divisor = "1";
MathContext mc = new MathContext(9,RoundingMode.DOWN);
I am getting the Exception.
java.lang.ArithmeticException: Division impossible
I am expecting the output as: 123456789000 with a scale of -3.
The java prototype version used is:
(build 1.5.0-internal-darcy_18_aug_2003_12_29)
The Test program is:
-------------------
import java.math.*;
public class Test {
public static void main(String args[]) throws Exception {
String dividend = "123456789000";
String divisor = "1";
BigDecimal dividendBD = new BigDecimal(dividend);
BigDecimal divisorBD = new BigDecimal(divisor);
MathContext mc = new MathContext(9,RoundingMode.DOWN);
BigDecimal quotientDivideInteger = dividendBD.divideToIntegralValue(divisorBD,mc);
System.out.println("quotientDivideInteger " + quotientDivideInteger.longValue() + " scale = " + quotientDivideInteger.scale());
}
}
---------------The output is----and java version used-------------
D:\testing>java Test
Exception in thread "main" java.lang.ArithmeticException: Division impossible
at java.math.BigDecimal.divideToIntegralValue(BigDecimal.java:1464)
at Test.main(Test.java:9)
D:\testing>java -version
java version "1.5.0-internal"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-internal-darcy_18_
aug_2003_12_29)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b15, mixed mode)
---------expected output is:
I am expecting the output as: 123456789000 with a scale of -3.
###@###.### 2003-09-03