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