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