This content has been marked as final. Show 6 replies
1 person found this helpful
How can I check a given Integer (not int) to see if it requires rounding, and then round down.That's easy. Whether it is an Integer or an integer it can never need rounding, whether up, down, or sideways. It doesn't have a fractional part to round.
if given Integer is 3456.9... the laws of Java must have been temporarily suspended. This is impossible.
Let me expand then.
If I have been passed an Integer 2345 I need to return the half of its value 'rounded down'.
ie 2345 / 2 = 1172 (I need to return 1172, not 1173 or 1172.5)
That's how integers behave already. If you assign a floating-point number to an integer (int or Integer) it will truncate the fraction part.
Thanks for putting up with my newbiness.
NumberFormat format = NumberFormat.getInstance();
Why? It already is an integer, it already is rounded down.
Please read the thread before contributing.