-1

我写了一小段代码:

BigDecimal nummer = new BigDecimal("8340337220.0");
BigDecimal denominator = new BigDecimal("17.O");
BigDecimal result = nummer.divide(denominator);
System.out.println(result);

在eclipse中运行它后,它给了我:

Exception in thread "main" java.lang.NumberFormatException
    at java.math.BigDecimal.<init>(BigDecimal.java:459)
    at java.math.BigDecimal.<init>(BigDecimal.java:728)
    at main.main(main.java:10)

有人能帮我吗?

4

2 回答 2

6

看起来你有一个大写字母“O” "17.O"。用零替换:

BigDecimal denominator = new BigDecimal("17.0");
于 2013-04-29T17:47:56.547 回答
0
BigDecimal nummer = new BigDecimal("83227720.0");
BigDecimal denominator = new BigDecimal("17.0");
BigDecimal result = nummer.divide(denominator,10,RoundingMode.DOWN);
System.out.println(result);
于 2013-04-29T18:16:52.207 回答