Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一堆整数需要向上或向下舍入到除以 25 的最接近的值。
例如:
417 轮到 425
405 舍入到 400
int roundedValue = (valueToRound + 12) / 25 * 25;
在任何值之前添加 25/2 以四舍五入到最接近的值
函数roundTo(值,舍入){ temp = value + rounding/2; return temp - temp%rounding; }