IMPLEMENTED printf()!!!!!!!

It's kinda bad :/
This commit is contained in:
2024-05-29 11:35:10 +02:00
parent f4f89dd8ba
commit ed18f4ac4b
6 changed files with 89 additions and 90 deletions
+4 -7
View File
@@ -6,19 +6,16 @@
// Source: http://www.strudel.org.uk/itoa/
char* itoa(uint32_t val, uint8_t base) {
static char buf[32] = { 0 };
if (base == 0 || base > 16) {
// TODO: Add errors!!
return NULL;
}
if (base == 0 || base > 16) { return NULL; }
if (val == 0) {
buf[0] = '0';
return buf;
}
int i = 30;
for (; val && i; i--, val /= base) {
int i;
for (i = 30; val && i; i--, val /= base) {
buf[i] = "0123456789abcdef"[val % base];
}