2
Answers

rounding to nearest .5

Ask a question
Thomas

Thomas

12y
4.3k
1
I had an interesting request and I'm wondering if there is a better way to do it

I have a percentage calculation and they are asking to have it round not to the nearest tenth but to the nearest .5. I can do it by checking what the last number is and writing code to round down to .0 or up to .5 if under .5 and Up to .0 or down to .5 if over. But that seems really clunky and more complex than needed.

Any other ideas out there?

Answers (2)