refactor math utility
All checks were successful
/ test (pull_request) Successful in 32s

This commit is contained in:
2026-01-17 15:44:50 +01:00
parent 62d6b8b01e
commit 4331145c34
12 changed files with 26 additions and 27 deletions

View File

@@ -1,7 +1,6 @@
package com.infendro.hash.util
internal fun ceil(x: Int, n: Int): Int =
((x + n - 1) / n) * n
internal fun ceilPow2(x: Int, n: Int): Int =
(x + n - 1) and (n - 1).inv()
internal fun Int.align(n: Int): Int = when {
n and (n - 1) == 0 -> (this + n - 1) and (n - 1).inv()
else -> ((this + n - 1) / n) * n
}