Jump to content

SOLVED: How to round up a BigDecimal


phantastes

Recommended Posts

Hi,

I want a value of 3.665 to be rounded to 3.67.

I have a field provided with a BigDecimal. The field is in a crosstab. I've set the field to show 2 decimal places. The problem I am having is that it doesn't seem to round correctly.

In the fields textfield I have:

$V{gpaAverageMeasure}.setScale(2, java.math.RoundingMode.HALF_UP)

Instead of rounding up to 3.67 it rounds down to 3.66.

Any help would be very welcome!

Magnus

 



Post Edited by phantastes at 03/23/2010 21:02



Post Edited by phantastes at 03/23/2010 22:46
Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

The above $V{gpaAverageMeasure}.setScale(2, java.math.RoundingMode.HALF_UP) , were $V{gpaAverageMeasure} is a BigDecimal, works.

I had pulled in floatValue() in the measure calculation which messed it up. So the short of it is, just use BigDecimal.

Magnus

Link to comment
Share on other sites

  • 5 years later...

Magnus how you solved it ? I have the same error.

But I use $F{FOB75}.setScale(2,BigDecimal. ROUND_HALF_UP).multiply($F{QRV075}.setScale(2,BigDecimal. ROUND_HALF_UP))   Where $F{FOB75} and $F{QRV075} are a bigDecimal field.

 

Any idea how to do that right.

Thank you,

EstebanR

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...