I need to do a custom rounding that works that way:
- If number is closer to 0, it is rounded down (1 or 2)
- If number is closer to 0.5, it is rounded to 0.5 (3, 4, 6 or 7)
- If number is closer to 1, it is rounded up (8 or 9)
What would be the best approach to this problem?
Edit: this question was already answered in "Java round to nearest .5". Thanks for the answers.