[Logo]
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
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Nov 18, 2017 20:25:59.