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