mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
Add itoa function
This commit is contained in:
1 parent
d1d5d5e18f
commit
e8a719d911
2 files changed
+17
No files matched your search
@@ -172,6 +172,22 @@ void write_char(char c)
|
||||
}
|
||||
|
||||
|
||||
void itoa(uint8_t v)
|
||||
{
|
||||
uint8_t t = (v / 100);
|
||||
// when print_zeros is not zero, we know that a non-zero number has printed.
|
||||
// That have to print all the next numbers.
|
||||
uint8_t print_zeros = t;
|
||||
if (print_zeros)
|
||||
write_char('0' + t);
|
||||
t = (v / 10) % 10;
|
||||
print_zeros |= t;
|
||||
if (print_zeros)
|
||||
write_char('0' + t);
|
||||
write_char('0' + (v % 10));
|
||||
}
|
||||
|
||||
|
||||
void print_string(__code char *p)
|
||||
{
|
||||
while (*p)
|
||||
|
||||
Reference in new issue
Block a user