Round a float to the nearest multiple of ?

后端 未结 2 1651
忘掉有多难
忘掉有多难 2021-01-29 15:57

How do I round a float value to the nearest multiple of \"n\"?

For instance, rounding 21.673 to the nearest multiple of 8 should result in 24.

And, rounding 21.6

2条回答
提交回复
热议问题