This commit is contained in:
2025-03-20 17:56:21 +08:00
parent 8d3c805985
commit 9ad083b014
19 changed files with 535 additions and 112 deletions

View File

@@ -0,0 +1,9 @@
/**
* 计算最接近的 x 的倍数
* @param n 输入的数字
* @param [x=16] 推荐使用偶数
* @returns 最近的 x 的倍数
*/
export function nearestMultiple(n: number, x: number = 16): number {
return Math.floor((n + x/2) / x) * x;
}