Debian Codegraph @

debian/external_deps/fetk/punc/src/vf2c/fmtlib.c

raw
1 /* @(#)fmtlib.c 1.2 */
2 #define MAXINTLENGTH 23
3
4 #include "f2c.h"
5 #ifdef __cplusplus
6 extern "C" {
7 #endif
8 #ifndef Allow_TYQUAD
9 #undef longint
10 #define longint long
11 #undef ulongint
12 #define ulongint unsigned long
13 #endif
14
15 #ifdef KR_headers
16 char *f__icvt(value,ndigit,sign, base) longint value; int *ndigit,*sign;
17 register int base;
18 #else
19 char *f__icvt(longint value, int *ndigit, int *sign, int base)
20 #endif
21 {
22 static char buf[MAXINTLENGTH+1];
23 register int i;
24 ulongint uvalue;
25
26 if(value > 0) {
27 uvalue = value;
28 *sign = 0;
29 }
30 else if (value < 0) {
31 uvalue = -value;
32 *sign = 1;
33 }
34 else {
35 *sign = 0;
36 *ndigit = 1;
37 buf[MAXINTLENGTH-1] = '0';
38 return &buf[MAXINTLENGTH-1];
39 }
40 i = MAXINTLENGTH;
41 do {
42 buf[--i] = (uvalue%base) + '0';
43 uvalue /= base;
44 }
45 while(uvalue > 0);
46 *ndigit = MAXINTLENGTH - i;
47 return &buf[i];
48 }
49 #ifdef __cplusplus
50 }
51 #endif