A poorly written OS for the x86 arch. (WIP)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
eOS/lib/util.c

17 lines
308 B

3 years ago
#include "util.h"
3 years ago
#include "math.h"
3 years ago
3 years ago
uint ulong_len(ulong n) { // get the digit length of a number
3 years ago
int len = 0;
3 years ago
while (n != 0) {
n = n / 10;
3 years ago
++len;
}
return len;
}
3 years ago
uint ndigit(ulong n, uint i) { // OBS: index order is reversed
long den = pow(10, i);
return (n/den) % 10;
3 years ago
}