summaryrefslogtreecommitdiff
path: root/fmt_ulong.c
diff options
context:
space:
mode:
Diffstat (limited to 'fmt_ulong.c')
-rw-r--r--fmt_ulong.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/fmt_ulong.c b/fmt_ulong.c
new file mode 100644
index 0000000..168572f
--- /dev/null
+++ b/fmt_ulong.c
@@ -0,0 +1,15 @@
1/* Public domain. */
2
3#include "fmt.h"
4
5unsigned int fmt_ulong(register char *s,register unsigned long u)
6{
7 register unsigned int len; register unsigned long q;
8 len = 1; q = u;
9 while (q > 9) { ++len; q /= 10; }
10 if (s) {
11 s += len;
12 do { *--s = '0' + (u % 10); u /= 10; } while(u); /* handles u == 0 */
13 }
14 return len;
15}