I have a float. I want to round it to the nearest multiple of n, where n is any float. How can I do this?
In my particular instance, I need my float to be a multiple of 0.96f, but 0.96f is subject to change.
For example, if I have 1.0f, I want to get 0.96f. Or if I have 1.75f, I want to get 1.92f. I do not need to account for negative numbers, although it would be good if it did.
I have checked the other questions about rounding, but they are all in powers of 2. (0.25, 0.5, 1, 2, etc.)