Files
hash.kt/src/commonMain/kotlin/com/infendro/hash/util/Math.kt
Infendro 4331145c34
All checks were successful
/ test (pull_request) Successful in 32s
refactor math utility
2026-01-17 15:44:50 +01:00

7 lines
175 B
Kotlin

package com.infendro.hash.util
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
}