|
Last change
on this file since 410 was 2, checked in by bird, 23 years ago |
|
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
|
|
File size:
818 bytes
|
| Line | |
|---|
| 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 | #ifdef KR_headers
|
|---|
| 14 | char *f__icvt(value,ndigit,sign, base) longint value; int *ndigit,*sign;
|
|---|
| 15 | register int base;
|
|---|
| 16 | #else
|
|---|
| 17 | char *f__icvt(longint value, int *ndigit, int *sign, int base)
|
|---|
| 18 | #endif
|
|---|
| 19 | {
|
|---|
| 20 | static char buf[MAXINTLENGTH+1];
|
|---|
| 21 | register int i;
|
|---|
| 22 | ulongint uvalue;
|
|---|
| 23 |
|
|---|
| 24 | if(value > 0) {
|
|---|
| 25 | uvalue = value;
|
|---|
| 26 | *sign = 0;
|
|---|
| 27 | }
|
|---|
| 28 | else if (value < 0) {
|
|---|
| 29 | uvalue = -value;
|
|---|
| 30 | *sign = 1;
|
|---|
| 31 | }
|
|---|
| 32 | else {
|
|---|
| 33 | *sign = 0;
|
|---|
| 34 | *ndigit = 1;
|
|---|
| 35 | buf[MAXINTLENGTH-1] = '0';
|
|---|
| 36 | return &buf[MAXINTLENGTH-1];
|
|---|
| 37 | }
|
|---|
| 38 | i = MAXINTLENGTH;
|
|---|
| 39 | do {
|
|---|
| 40 | buf[--i] = (uvalue%base) + '0';
|
|---|
| 41 | uvalue /= base;
|
|---|
| 42 | }
|
|---|
| 43 | while(uvalue > 0);
|
|---|
| 44 | *ndigit = MAXINTLENGTH - i;
|
|---|
| 45 | return &buf[i];
|
|---|
| 46 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.