How to sum BigDecimal values


Hi ,

I am new to java,I am trying to add the two BigDecimal values,

Please help some one,

How to add BigDecimal values.


Thanks in advance,




kunkasurendra's picture
Joined: Jun 12 2007 - 3:43pm
Last seen: 1 year 10 months ago

2 Answers:

svenn's picture
Joined: Mar 19 2007 - 5:57am
Last seen: 13 years 3 months ago

The API is good if you want to do precision mathematics, but let me give you an easier answer.

You can't add two BigDecimals together because that would be crashing two objects into each other, essentially. :-)

Your best bet is to take the .doubleValue() of each and add those together, since that method returns a primitive type that you can do arithmetic on.

$F{MYDECIMAL1}.doubleValue() + $F{MYDECIMAL2}.doubleValue()</td></tr></tbody></table>
aetherflux's picture
Joined: Apr 11 2007 - 10:30pm
Last seen: 6 years 7 months ago