Post a reply

Write your message and submit

Options

Click in the dark area of the image to send your post.

Go back

Topic review (newest first)

phobucket
2012-05-22 17:02:15

Hi buzzy,

What is the input data type?  Also, float is only 32bit, so depending on the size of your number, you might lose precision after you round.  Double or BigDecimal may be a better choice.

For a double, you could use this to round: (Math.round(myField*100.0))/100.0
For a BigDecimal, you could use this to round: myField.setScale(2, BigDecimal.ROUND_HALF_UP)

Thanks,
Ben

buzzy96
2012-05-22 14:04:08

hi,

pls let me know any one...

round to 2 dp with Float.ValueOf()?


thx

Board footer

Powered by FluxBB