synth/arm/itoa.h

14 lines
313 B
C
Raw Normal View History

2022-05-17 03:56:25 +00:00
#pragma once
// out must be at least 8 bytes long
inline void itoa(int val, char* out) {
for (int i = 0; i < 8; i++) {
uint8_t digit = (val >> (28 - 4 * i)) & 0xf;
if (digit < 0xa) {
out[i] = '0' + digit;
} else {
out[i] = 'a' + digit - 0xa;
}
}
}