aboutsummaryrefslogtreecommitdiff
path: root/fmt_ulong.c
diff options
context:
space:
mode:
Diffstat (limited to 'fmt_ulong.c')
-rw-r--r--fmt_ulong.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/fmt_ulong.c b/fmt_ulong.c
new file mode 100644
index 0000000..db48bfd
--- /dev/null
+++ b/fmt_ulong.c
@@ -0,0 +1,13 @@
+#include "fmt.h"
+
+unsigned int fmt_ulong(register char *s,register unsigned long u)
+{
+ register unsigned int len; register unsigned long q;
+ len = 1; q = u;
+ while (q > 9) { ++len; q /= 10; }
+ if (s) {
+ s += len;
+ do { *--s = '0' + (u % 10); u /= 10; } while(u); /* handles u == 0 */
+ }
+ return len;
+}