diff --git a/src/libs/karm-math/funcs.h b/src/libs/karm-math/funcs.h index 3d73e5899d..4678ef0713 100644 --- a/src/libs/karm-math/funcs.h +++ b/src/libs/karm-math/funcs.h @@ -38,6 +38,27 @@ static constexpr bool isNegInf(f64 x) { // MARK: Rounding + Remainder -------------------------------------------------- +template +constexpr isize floori(T x) { + if (x < 0) + return (long)(x - 1); + + return (long)x; +} + +template +constexpr isize ceili(T x) { + if (x < 0) + return (long)x; + + return (long)(x + 1); +} + +template +constexpr isize roundi(T x) { + return (long)(x + 0.5); +} + template constexpr T floor(T x) { if (x < 0) @@ -54,8 +75,9 @@ constexpr T ceil(T x) { return (T)(long)(x + 1); } -constexpr isize round(f64 x) { - return (isize)(x + 0.5); +template +constexpr T round(T x) { + return (T)(long)(x + 0.5); } // MARK: Trigonometry ----------------------------------------------------------