I am working on a MySql backed Jasper report. I have 5 BigDecimal Variables in my report. This report calculates the yearly charge of multiple services .I need to add the first 4 and the subtract the last one. Some of these these variables can potentially house fairly large values ( 8 figures ). I donot know how to do calculations is BigDecimal. I have tried making a Double variable and doing the following
Double.valueOf($V{enc}.doubleValue() + $V{Bed}.doubleValue()+$V{Diet}.doubleValue() + $V{Investigation}.doubleValue() - $V{ref}.doubleValue())
The report does not give any error but leads to 7.269307848E9 as shown below:
254350, 14589, 8122, 3708, 0 7.269307848E9
( these are the values of the original variables except the last one which is the result of the calculation )
While searching for the solution, I did come across the following:
($V{enc}.ADD($V{Bed})).toString()
I am not sure how I can apply it in my case. This can add only two values.
I need to have a whole value, not decimal like above. By the way, I use iReport 1.2.0, which is a requirement for generating the report.