File: fmt_number.h

package info (click to toggle)
ngetty 1.0-1
  • links: PTS
  • area: main
  • in suites: squeeze, wheezy
  • size: 304 kB
  • ctags: 207
  • sloc: ansic: 1,503; makefile: 236; sh: 109; asm: 100
file content (11 lines) | stat: -rw-r--r-- 261 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
#define fmt_number_macro(f,type,base) \
unsigned int f(char *s, type u) { \
  type tmp=u;\
  unsigned int len=1;\
  while (tmp >= base) { tmp /=10; ++len; }\
  if (s) {\
    s +=len;\
    do { *--s = '0' +(u%base); u /=base; } while (u);\
  }\
  return len;\
}