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....
Post by:chi Lin
, Ranch Hand
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
This thread has been viewed 530 times.
All times above are in ranch (not your local) time.
The current ranch time is Oct 21, 2018 11:45:14.