1 /****************************************************************
2 
3 The author of this software is David M. Gay.
4 
5 Copyright (C) 1998 by Lucent Technologies
6 All Rights Reserved
7 
8 Permission to use, copy, modify, and distribute this software and
9 its documentation for any purpose and without fee is hereby
10 granted, provided that the above copyright notice appear in all
11 copies and that both that the copyright notice and this
12 permission notice and warranty disclaimer appear in supporting
13 documentation, and that the name of Lucent or any of its entities
14 not be used in advertising or publicity pertaining to
15 distribution of the software without specific, written prior
16 permission.
17 
18 LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
19 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
20 IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
21 SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
22 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
23 IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
24 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
25 THIS SOFTWARE.
26 
27 ****************************************************************/
28 
29 /* Please send bug reports to David M. Gay (dmg at acm dot org,
30  * with " at " changed at "@" and " dot " changed to ".").	*/
31 
32 /* Modified by Danny Smith for inclusion in libmingwex.a
33    Aug 2006  */
34 
35 #ifndef GDTOA_H_INCLUDED
36 #define GDTOA_H_INCLUDED
37 
38 #include "gd_arith.h"
39 #include <stddef.h> /* for size_t */
40 
41 #if defined(__MINGW32__) || defined(__MINGW64__)
42 /* keep the 'Long' definition as 'long' for compatibility
43  * with older/other software. long in w64 is 32 bits anyway..
44  */
45 #define Long long	/* Windows long is 32 bit */
46 #undef  NO_LONG_LONG	/* we have long long type */
47 #endif	/* MinGW */
48 
49 #ifndef Long
50 #define Long int
51 #endif
52 #ifndef ULong
53 typedef unsigned Long ULong;
54 #endif
55 #ifndef UShort
56 typedef unsigned short UShort;
57 #endif
58 
59 enum {	/* return values from strtodg */
60 	STRTOG_Zero	= 0,
61 	STRTOG_Normal	= 1,
62 	STRTOG_Denormal	= 2,
63 	STRTOG_Infinite	= 3,
64 	STRTOG_NaN	= 4,
65 	STRTOG_NaNbits	= 5,
66 	STRTOG_NoNumber	= 6,
67 	STRTOG_Retmask	= 7,
68 
69 	/* The following may be or-ed into one of the above values. */
70 
71 	STRTOG_Neg	= 0x08, /* does not affect STRTOG_Inexlo or STRTOG_Inexhi */
72 	STRTOG_Inexlo	= 0x10,	/* returned result rounded toward zero */
73 	STRTOG_Inexhi	= 0x20, /* returned result rounded away from zero */
74 	STRTOG_Inexact	= 0x30,
75 	STRTOG_Underflow= 0x40,
76 	STRTOG_Overflow	= 0x80
77 };
78 
79 typedef struct
80 FPI {
81 	int nbits;
82 	int emin;
83 	int emax;
84 	int rounding;
85 	int sudden_underflow;
86 	int int_max;
87 } FPI;
88 
89 enum {	/* FPI.rounding values: same as FLT_ROUNDS */
90 	FPI_Round_zero = 0,
91 	FPI_Round_near = 1,
92 	FPI_Round_up = 2,
93 	FPI_Round_down = 3
94 };
95 
96 #ifdef __cplusplus
97 extern "C" {
98 #endif
99 
100 extern char* __dtoa (double d, int mode, int ndigits, int *decpt,
101 		     int *sign, char **rve);
102 extern char* __gdtoa (FPI *fpi, int be, ULong *bits, int *kindp,
103 		     int mode, int ndigits, int *decpt, char **rve);
104 extern void __freedtoa (char *);
105 
106 extern float  __strtof (const char *, char **);
107 extern double __strtod (const char *, char **);
108 extern long double __strtold (const char *, char **);
109 extern int __strtodg (const char *, char **, FPI *, Long *, ULong *);
110 
111 extern char*	__g__fmt   (char*, char*, char*, int, ULong, size_t);
112 extern char*	__g_dfmt   (char*, double*, int, size_t);
113 extern char*	__g_ffmt   (char*, float*,  int, size_t);
114 extern char*	__g_xfmt   (char*, void*,   int, size_t);
115 
116 #ifdef __cplusplus
117 }
118 #endif
119 #endif /* GDTOA_H_INCLUDED */
120