S
sami.jan
Hi
I am new to Java. I have to use BigDecimal to do some data conversions
(app limitation) and have run into something I cannot understand.
------
BigDecimal bd, bd2;
bd2 = new BigDecimal(12345678901); //This throws an error - Out of
Range
bd = new BigDecimal("12345678901");
bd2 = new BigDecimal("12345678901");
System.out.println(bd.add(bd2));
Output for the last line is: 24691357802 (i.e. addition was successful)
------
How can this work? If 12345678901 is out of range, how can
"12345678901" be in range? and math operations for these bigdecimals
work too
Thanks
Sami
I am new to Java. I have to use BigDecimal to do some data conversions
(app limitation) and have run into something I cannot understand.
------
BigDecimal bd, bd2;
bd2 = new BigDecimal(12345678901); //This throws an error - Out of
Range
bd = new BigDecimal("12345678901");
bd2 = new BigDecimal("12345678901");
System.out.println(bd.add(bd2));
Output for the last line is: 24691357802 (i.e. addition was successful)
------
How can this work? If 12345678901 is out of range, how can
"12345678901" be in range? and math operations for these bigdecimals
work too
Thanks
Sami