Forums Register Login
Rounding up of values..
Hello world,
When I use the Float.parseFloat(String s) method it rounds up the value. For example 35.444 is rounded up to 35.45. For my requirements, I don't wont this to happen. Could you please tell me how to stop this rounding up values.
Thank you very much....
The Float.parseFloat("35.444") works as expected on my machine.

However, you can use BigDecimal from java.math package to get more precision control.
BigDecimal b1 = new BigDecimal (String.valueOf(35.444));
System.out.println(b1); // prints 35.444
Die Fledermaus does not fear such a tiny ad:
Rocket Oven Kickstarter - from the trailboss

This thread has been viewed 499 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jul 16, 2018 04:48:30.