diff options
Diffstat (limited to 'usr/string.c')
-rw-r--r-- | usr/string.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/usr/string.c b/usr/string.c new file mode 100644 index 0000000..8c94900 --- /dev/null +++ b/usr/string.c @@ -0,0 +1,19 @@ +char* ulong_to_string(unsigned long value, char* data) +{ + unsigned long t = value; + unsigned long c; + char* dptr = data + 10; + for (int i = 0; i <= 10; i++) { + c = t%10; + *dptr = 0x30 + (c&0xF); + t /= 10; + if (t==0) + break; + dptr -= 1; + if (i == 5) { + *dptr = '.'; + dptr -= 1; + } + } + return dptr; +} |