sl@0
|
1 |
/****************************************************************
|
sl@0
|
2 |
|
sl@0
|
3 |
The author of this software is David M. Gay.
|
sl@0
|
4 |
|
sl@0
|
5 |
Copyright (C) 1998 by Lucent Technologies
|
sl@0
|
6 |
All Rights Reserved
|
sl@0
|
7 |
|
sl@0
|
8 |
Permission to use, copy, modify, and distribute this software and
|
sl@0
|
9 |
its documentation for any purpose and without fee is hereby
|
sl@0
|
10 |
granted, provided that the above copyright notice appear in all
|
sl@0
|
11 |
copies and that both that the copyright notice and this
|
sl@0
|
12 |
permission notice and warranty disclaimer appear in supporting
|
sl@0
|
13 |
documentation, and that the name of Lucent or any of its entities
|
sl@0
|
14 |
not be used in advertising or publicity pertaining to
|
sl@0
|
15 |
distribution of the software without specific, written prior
|
sl@0
|
16 |
permission.
|
sl@0
|
17 |
|
sl@0
|
18 |
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
sl@0
|
19 |
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
sl@0
|
20 |
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
|
sl@0
|
21 |
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
sl@0
|
22 |
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
sl@0
|
23 |
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
sl@0
|
24 |
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
sl@0
|
25 |
THIS SOFTWARE.
|
sl@0
|
26 |
|
sl@0
|
27 |
****************************************************************/
|
sl@0
|
28 |
|
sl@0
|
29 |
/* Please send bug reports to
|
sl@0
|
30 |
David M. Gay
|
sl@0
|
31 |
Bell Laboratories, Room 2C-463
|
sl@0
|
32 |
600 Mountain Avenue
|
sl@0
|
33 |
Murray Hill, NJ 07974-0636
|
sl@0
|
34 |
U.S.A.
|
sl@0
|
35 |
dmg@bell-labs.com
|
sl@0
|
36 |
*/
|
sl@0
|
37 |
|
sl@0
|
38 |
#ifndef GDTOA_H_INCLUDED
|
sl@0
|
39 |
#define GDTOA_H_INCLUDED
|
sl@0
|
40 |
|
sl@0
|
41 |
#include "arith.h"
|
sl@0
|
42 |
|
sl@0
|
43 |
#ifndef Long
|
sl@0
|
44 |
#define Long long
|
sl@0
|
45 |
#endif
|
sl@0
|
46 |
#ifndef ULong
|
sl@0
|
47 |
typedef unsigned Long ULong;
|
sl@0
|
48 |
#endif
|
sl@0
|
49 |
#ifndef UShort
|
sl@0
|
50 |
typedef unsigned short UShort;
|
sl@0
|
51 |
#endif
|
sl@0
|
52 |
|
sl@0
|
53 |
#ifndef ANSI
|
sl@0
|
54 |
#ifdef KR_headers
|
sl@0
|
55 |
#define ANSI(x) ()
|
sl@0
|
56 |
#define Void /*nothing*/
|
sl@0
|
57 |
#else
|
sl@0
|
58 |
#define ANSI(x) x
|
sl@0
|
59 |
#define Void void
|
sl@0
|
60 |
#endif
|
sl@0
|
61 |
#endif /* ANSI */
|
sl@0
|
62 |
|
sl@0
|
63 |
#ifndef CONST
|
sl@0
|
64 |
#ifdef KR_headers
|
sl@0
|
65 |
#define CONST /* blank */
|
sl@0
|
66 |
#else
|
sl@0
|
67 |
#define CONST const
|
sl@0
|
68 |
#endif
|
sl@0
|
69 |
#endif /* CONST */
|
sl@0
|
70 |
|
sl@0
|
71 |
enum { /* return values from strtodg */
|
sl@0
|
72 |
STRTOG_Zero = 0,
|
sl@0
|
73 |
STRTOG_Normal = 1,
|
sl@0
|
74 |
STRTOG_Denormal = 2,
|
sl@0
|
75 |
STRTOG_Infinite = 3,
|
sl@0
|
76 |
STRTOG_NaN = 4,
|
sl@0
|
77 |
STRTOG_NaNbits = 5,
|
sl@0
|
78 |
STRTOG_NoNumber = 6,
|
sl@0
|
79 |
STRTOG_Retmask = 7,
|
sl@0
|
80 |
|
sl@0
|
81 |
/* The following may be or-ed into one of the above values. */
|
sl@0
|
82 |
|
sl@0
|
83 |
STRTOG_Neg = 0x08,
|
sl@0
|
84 |
STRTOG_Inexlo = 0x10,
|
sl@0
|
85 |
STRTOG_Inexhi = 0x20,
|
sl@0
|
86 |
STRTOG_Inexact = 0x30,
|
sl@0
|
87 |
STRTOG_Underflow= 0x40,
|
sl@0
|
88 |
STRTOG_Overflow = 0x80
|
sl@0
|
89 |
};
|
sl@0
|
90 |
|
sl@0
|
91 |
typedef struct
|
sl@0
|
92 |
FPI {
|
sl@0
|
93 |
int nbits;
|
sl@0
|
94 |
int emin;
|
sl@0
|
95 |
int emax;
|
sl@0
|
96 |
int rounding;
|
sl@0
|
97 |
int sudden_underflow;
|
sl@0
|
98 |
} FPI;
|
sl@0
|
99 |
|
sl@0
|
100 |
enum { /* FPI.rounding values: same as FLT_ROUNDS */
|
sl@0
|
101 |
FPI_Round_zero = 0,
|
sl@0
|
102 |
FPI_Round_near = 1,
|
sl@0
|
103 |
FPI_Round_up = 2,
|
sl@0
|
104 |
FPI_Round_down = 3
|
sl@0
|
105 |
};
|
sl@0
|
106 |
|
sl@0
|
107 |
#ifdef __cplusplus
|
sl@0
|
108 |
extern "C" {
|
sl@0
|
109 |
#endif
|
sl@0
|
110 |
|
sl@0
|
111 |
extern char* dtoa ANSI((double d, int mode, int ndigits, int *decpt,
|
sl@0
|
112 |
int *sign, char **rve));
|
sl@0
|
113 |
extern char* gdtoa ANSI((FPI *fpi, int be, ULong *bits, int *kindp,
|
sl@0
|
114 |
int mode, int ndigits, int *decpt, char **rve));
|
sl@0
|
115 |
extern void freedtoa ANSI((char*));
|
sl@0
|
116 |
extern float strtof ANSI((CONST char *, char **));
|
sl@0
|
117 |
extern double strtod ANSI((CONST char *, char **));
|
sl@0
|
118 |
extern int strtodg ANSI((CONST char*, char**, FPI*, Long*, ULong*));
|
sl@0
|
119 |
|
sl@0
|
120 |
extern char* g_ddfmt ANSI((char*, double*, int, unsigned));
|
sl@0
|
121 |
extern char* g_dfmt ANSI((char*, double*, int, unsigned));
|
sl@0
|
122 |
extern char* g_ffmt ANSI((char*, float*, int, unsigned));
|
sl@0
|
123 |
extern char* g_Qfmt ANSI((char*, void*, int, unsigned));
|
sl@0
|
124 |
extern char* g_xfmt ANSI((char*, void*, int, unsigned));
|
sl@0
|
125 |
extern char* g_xLfmt ANSI((char*, void*, int, unsigned));
|
sl@0
|
126 |
|
sl@0
|
127 |
extern int strtoId ANSI((CONST char*, char**, double*, double*));
|
sl@0
|
128 |
extern int strtoIdd ANSI((CONST char*, char**, double*, double*));
|
sl@0
|
129 |
extern int strtoIf ANSI((CONST char*, char**, float*, float*));
|
sl@0
|
130 |
extern int strtoIQ ANSI((CONST char*, char**, void*, void*));
|
sl@0
|
131 |
extern int strtoIx ANSI((CONST char*, char**, void*, void*));
|
sl@0
|
132 |
extern int strtoIxL ANSI((CONST char*, char**, void*, void*));
|
sl@0
|
133 |
extern int strtord ANSI((CONST char*, char**, int, double*));
|
sl@0
|
134 |
extern int strtordd ANSI((CONST char*, char**, int, double*));
|
sl@0
|
135 |
extern int strtorf ANSI((CONST char*, char**, int, float*));
|
sl@0
|
136 |
extern int strtorQ ANSI((CONST char*, char**, int, void*));
|
sl@0
|
137 |
extern int strtorx ANSI((CONST char*, char**, int, void*));
|
sl@0
|
138 |
extern int strtorxL ANSI((CONST char*, char**, int, void*));
|
sl@0
|
139 |
#if 1
|
sl@0
|
140 |
extern int strtodI ANSI((CONST char*, char**, double*));
|
sl@0
|
141 |
extern int strtopd ANSI((CONST char*, char**, double*));
|
sl@0
|
142 |
extern int strtopdd ANSI((CONST char*, char**, double*));
|
sl@0
|
143 |
extern int strtopf ANSI((CONST char*, char**, float*));
|
sl@0
|
144 |
extern int strtopQ ANSI((CONST char*, char**, void*));
|
sl@0
|
145 |
extern int strtopx ANSI((CONST char*, char**, void*));
|
sl@0
|
146 |
extern int strtopxL ANSI((CONST char*, char**, void*));
|
sl@0
|
147 |
#else
|
sl@0
|
148 |
#define strtopd(s,se,x) strtord(s,se,1,x)
|
sl@0
|
149 |
#define strtopdd(s,se,x) strtordd(s,se,1,x)
|
sl@0
|
150 |
#define strtopf(s,se,x) strtorf(s,se,1,x)
|
sl@0
|
151 |
#define strtopQ(s,se,x) strtorQ(s,se,1,x)
|
sl@0
|
152 |
#define strtopx(s,se,x) strtorx(s,se,1,x)
|
sl@0
|
153 |
#define strtopxL(s,se,x) strtorxL(s,se,1,x)
|
sl@0
|
154 |
#endif
|
sl@0
|
155 |
|
sl@0
|
156 |
#ifdef __cplusplus
|
sl@0
|
157 |
}
|
sl@0
|
158 |
#endif
|
sl@0
|
159 |
#endif /* GDTOA_H_INCLUDED */
|