convert « bigdecimal « Java Data Type Q&A

1. Converting BigDecimal to double

Hello, I am getting random run time exception when converting BigDecimal to double. The exception is the NumberFormatException. Since we are doing lots of scientific calucaltion, our precision is up to 14 position after the decimal point. The exception is as the followings: java.lang.NumberFormatException: For input string: "0.0000000000null" I am sure the input string isn't "0.0000000000null" when I use it to ...

2. converting bigdecimal

3. Double to BigDecimal Conversion problems

Hi, I have got 2 questions here. I would like to know why the following conversion is messed up. class test{ public static void main(String[] args){ System.out.println(new java.math.BigDecimal(1101100111001001110110001100100.0d)); System.out.println(1101100111001001110110001100100.0d); } } As you may see, the BigDecimal is way off the mark. Why is it so? The second question is, why is it so inconvenient to perform arithmetic on BigDecimals? I ...

4. Conversion to BigDecimal

5. good way to convert list to list

6. failure to convert infinite double to BigDecimal

I need to convert double to BigDecimal. But one of the double values is infinite and is not converted into the BigDecimal. I am getting this error. java.lang.NumberFormatException: Infinite or NaN. This is how I am converting it. private BigDecimal convert(Double object) { return new BigDecimal(object); } Does anybody know how to do this? Thanks.

7. problem with bigdecimal conversion

Hi, I want to convert the double number 25000000 to BigDecimal, but the result that I get is 2.5E+7 and this number causes that the application throws an exception. I'm doing it this way: double number=25000000; String value = Double.toString(number); BigDecimal bd = new BigDecimal(value); The funny thing is that if I try with 25000000.12 it works fine... I tried to ...