updated math functions
This commit is contained in:
@@ -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--;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user