Maybe?
This commit is contained in:
parent
6d47e897c5
commit
319c0d2772
@ -39,6 +39,8 @@
|
||||
if (sstrlen(input, 15) > 4) {
|
||||
char *number = input + 4;
|
||||
kprint(number);
|
||||
int result = digit_conver(number);
|
||||
kprint(result);
|
||||
}
|
||||
umem_head = add_node( umem_head, 0x10000, 0x100, true, global_id++);
|
||||
} else if (strcmp(input, "LIST") == 0) {
|
||||
@ -107,17 +109,17 @@
|
||||
|
||||
|
||||
int digconver(const char *str) {
|
||||
int result = 0;
|
||||
int i = 0;
|
||||
|
||||
while (str[i] != '\0') {
|
||||
if (str[i] >= '0' && str[i] <= '9') {
|
||||
result = result * 10 + (str[i] - '0');
|
||||
u32 result = 0;
|
||||
while (*hexString != '\0') {
|
||||
char hexChar = *hexString;
|
||||
if ((hexChar >= '0' && hexChar <= '9') || (hexChar >= 'A' && hexChar <= 'F')) {
|
||||
int digit = (hexChar >= '0' && hexChar <= '9') ? (hexChar - '0') : (10 + (hexChar - 'A'));
|
||||
result = result * 16 + digit;
|
||||
} else {
|
||||
kprint("Error - Provided input is not a valid number.\n");
|
||||
return 0;
|
||||
kprint("Invalid hex input\n");
|
||||
return -1;
|
||||
}
|
||||
i++;
|
||||
hexString++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user