diff options
| author | James Barnett <noreply@jamesbarnett.xyz> | 2019-10-06 12:56:26 +0100 |
|---|---|---|
| committer | James Barnett <noreply@jamesbarnett.xyz> | 2019-10-06 12:56:26 +0100 |
| commit | 64aa82592c6c2b043d8c62100d4ce110bf616c1e (patch) | |
| tree | 73387e2516ac2b7066c43ebf2dbe76e313edbcfc /os/stdlib | |
| parent | bd77381c27ef5b61bf1c123efef3895b98a7a615 (diff) | |
| download | tinyOS-64aa82592c6c2b043d8c62100d4ce110bf616c1e.tar.xz tinyOS-64aa82592c6c2b043d8c62100d4ce110bf616c1e.zip | |
Add os statusbar. Start stdlib
Diffstat (limited to 'os/stdlib')
| -rw-r--r-- | os/stdlib/sdtlib.h | 1 | ||||
| -rw-r--r-- | os/stdlib/stdlib.c | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/os/stdlib/sdtlib.h b/os/stdlib/sdtlib.h new file mode 100644 index 0000000..a0b3402 --- /dev/null +++ b/os/stdlib/sdtlib.h @@ -0,0 +1 @@ +char* int_to_str(int i);
\ No newline at end of file diff --git a/os/stdlib/stdlib.c b/os/stdlib/stdlib.c new file mode 100644 index 0000000..465e978 --- /dev/null +++ b/os/stdlib/stdlib.c @@ -0,0 +1,21 @@ +char* int_to_str(int i) +{ + // Room for 4 byte int, -ve sign and null terminator + static char buf[12]; + char *p = buf + 11; // points to null terminator + if (i >= 0) { + do { + *--p = '0' + (i % 10); + i /= 10; + } while (i != 0); + return p; + } + else { + do { + *--p = '0' - (i % 10); + i /= 10; + } while (i != 0); + *--p = '-'; + } + return p; +}
\ No newline at end of file |