Mercurial > hg > cdb
comparison fmt_ulong.c @ 0:2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
retrieved 2025-01-03,
contents appear to have been create on 2000-02-19
| author | Henry S. Thompson <ht@inf.ed.ac.uk> |
|---|---|
| date | Wed, 29 Jan 2025 10:50:34 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:2cb46628feec |
|---|---|
| 1 #include "fmt.h" | |
| 2 | |
| 3 unsigned int fmt_ulong(register char *s,register unsigned long u) | |
| 4 { | |
| 5 register unsigned int len; register unsigned long q; | |
| 6 len = 1; q = u; | |
| 7 while (q > 9) { ++len; q /= 10; } | |
| 8 if (s) { | |
| 9 s += len; | |
| 10 do { *--s = '0' + (u % 10); u /= 10; } while(u); /* handles u == 0 */ | |
| 11 } | |
| 12 return len; | |
| 13 } |
