updated math functions

This commit is contained in:
hugogogo
2025-03-15 18:15:30 +01:00
parent 16a5bcd313
commit ec928d14b1
12 changed files with 200 additions and 66 deletions

View File

@@ -6,4 +6,27 @@ void int_to_hex_string(uint64_t value, char *out, uint8_t num_digits) { // nu
out[i] = INT_TO_HEX_CHAR((value >> shift) & 0x0F);
}
out[num_digits] = '\0';
}
}
void int_to_string(uint64_t value, char *buffer) {
// handle zero case
if (value == 0) {
buffer[0] = '0';
return;
}
uint8_t size = -1;
uint64_t copy = value;
while (copy) {
copy /= 10;
size++;
}
while (value) {
uint8_t digit = value % 10;
buffer[size] = digit + '0';
value /= 10;
size--;
}
}