I have to format a float in Java differently depending on different values. For instance
23 format to 23
24.15 format to 24.15
30.249 format to 30.25
42.7 format to 42.7
That is, round up from the 100th place but do not display final 0's to the right (that is 3.4 instead of 3.40 and 7 instead of 7.0) etc. But again two decimal places max.
I was playing around with String.format but cannot figure out the correct format. I do need to format the float and write it to a String though.
Anyone have an idea what the format should be, or some other way to format the number (into a string)?