diff --git a/AK/IntegralMath.h b/AK/IntegralMath.h index e7ea6f6f76..c1051fed84 100644 --- a/AK/IntegralMath.h +++ b/AK/IntegralMath.h @@ -75,4 +75,16 @@ constexpr bool is_power_of(U x) return true; } +template +constexpr T reinterpret_as_octal(T decimal) +{ + T result = 0; + T n = 0; + while (decimal > 0) { + result += pow(8, n++) * (decimal % 10); + decimal /= 10; + } + return result; +} + }