IReport - Multiplication Error

Hi All,

     I am trying to do a multiplication on two fields

              1) PCS       (of type java.math.BigDecimal)
              2) AMOUNT (of type java.lang.Double)

     and I store the result in another field named "Result". The expression used for this calculation is as below

    new Double( $F{PCS}.doubleValue() * $F{AMOUNT}.doubleValue() )

For input values:

    PCS       - 6 and
    AMOUNT - 52.85

the output is coming correctly as 317.10
but when the input values are

    PCS       - 4 and
    AMOUNT - 117.92

the output is coming as 471.66 in the pdf report which is wrong, the value should had been 471.68
Could you guys help me to solve it?

I think the value of AMOUNT is 117.915 and not 117.92. (See the precision in both the values)

I would suggest printing the exact value of AMOUNT and PCS in your reports and then see what it calculates.

Remember the numbers are not rounded off, until and unless we instruct the java to do that

Hi Mr.sumit1001,

Thanks for your valueable inputs. Of course, the original value is “117.915”.

Corrected the reports to have the decimal points increased to 3 digits.