.NET method to round a number up to the nearest multiple of another number?

后端 未结 4 812
南笙
南笙 2020-12-31 08:11

I\'m looking for a method that can round a number up to the nearest multiple of another. This is similar Quantization.

Eg. If I want to round 81 up to the

4条回答
  •  离开以前
    2020-12-31 09:00

    Yes, integer arithmetic.

    To round m up to the next multiple of n, use ((m+n-1)/n)*n

提交回复
热议问题