MCPcopy Create free account
hub / github.com/acl-dev/acl / number

Function number

lib_acl/src/stdlib/acl_vsprintf.c:30–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28 int base, int size, int precision, int type)
29#else
30static char * number(char * buf, char * end, long int num,
31 int base, int size, int precision, int type)
32#endif
33{
34 char c,sign,tmp[66];
35 const char *digits;
36 const char small_digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
37 const char large_digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
38 int i;
39
40 digits = (type & LARGE) ? large_digits : small_digits;
41 if (type & LEFT)
42 type &= ~ZEROPAD;
43 if (base < 2 || base > 36)
44 return 0;
45 c = (type & ZEROPAD) ? '0' : ' ';
46 sign = 0;
47 if (type & SIGN) {
48 if (num < 0) {
49 sign = '-';
50 num = -num;
51 size--;
52 } else if (type & PLUS) {
53 sign = '+';
54 size--;
55 } else if (type & SPACE) {
56 sign = ' ';
57 size--;
58 }
59 }
60 if (type & SPECIAL) {
61 if (base == 16)
62 size -= 2;
63 else if (base == 8)
64 size--;
65 }
66 i = 0;
67 if (num == 0)
68 tmp[i++]='0';
69 else {
70 while (num != 0) {
71#ifdef _WIN64
72 long long int __res;
73 __res = ((unsigned long int) num) % (unsigned) base;
74 num = ((unsigned long int) num) / (unsigned) base;
75#else
76 long int __res;
77 __res = ((unsigned long int) num) % (unsigned) base;
78 num = ((unsigned long int) num) / (unsigned) base;
79#endif
80
81 tmp[i++] = digits[__res];
82 }
83 }
84 if (i > precision)
85 precision = i;
86 size -= precision;
87 if (!(type&(ZEROPAD+LEFT))) {

Callers 1

acl_vsnprintfFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…