I'm making a calculation and I'm getting 12,443. I want to round it to 12,40. This is the way I'm trying to do it but I'm getting 12 instead of 12,40
float result = Math.round( (new Float(result1)*0.3) + (new Float(result2)*0.7) );
vprosvasis.setText( Float.toString(result) );
Examples:
So, the final number will always be in ##.@ format
(float)Math.round(value * 10) / 10
should give you the result you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With