what's the most elegant way of rounding a float to it's closest 1/4ths in Objective C?
For example:
3.14 should be 3.25
2.72 should be 2.75
6.62 should be 6.50
1.99 should be 2.00
etc.
what's the most elegant way of rounding a float to it's closest 1/4ths in Objective C?
For example:
3.14 should be 3.25
2.72 should be 2.75
6.62 should be 6.50
1.99 should be 2.00
etc.
One approach is to use an NSNumberFormatter
with a rounding increment and rounding mode set. You can then access the float value. Obviously, this assumes Cocoa and is more than a little heavy-handed.