diff --git a/kernel/inc/utils/math.h b/kernel/inc/utils/math.h index 69e8446..26d3cea 100644 --- a/kernel/inc/utils/math.h +++ b/kernel/inc/utils/math.h @@ -25,6 +25,7 @@ #define NOX_MATH_H #include "stdtypes.h" +#include "string.h" #define MAX(a, b) (a > b ? a : b) #define MIN(a, b) (a > b ? b : a) @@ -36,7 +37,8 @@ typedef struct { uint64_t y; } position_T; -uint64_t pow(uint64_t base, uint64_t exp); -uint64_t abs(int64_t n); +uint64_t pow (uint64_t base, uint64_t exp); +uint64_t abs (int64_t n); +uint64_t octal_string_to_int (string_t string, uint8_t size); #endif //NOX_MATH_H diff --git a/kernel/src/utils/math.c b/kernel/src/utils/math.c index ad74787..b4c60dc 100644 --- a/kernel/src/utils/math.c +++ b/kernel/src/utils/math.c @@ -36,4 +36,13 @@ uint64_t abs(int64_t n) { return n * -1; } return n; +} + +uint64_t octal_string_to_int(string_t string, uint8_t size) { + uint64_t n = 0; + for (int i = 0; i < size; i++) { + n *= 8; + n += string[i] - '0'; + } + return n; } \ No newline at end of file