master
1/****************************************************************
2
3The author of this software is David M. Gay.
4
5Copyright (C) 1998 by Lucent Technologies
6All Rights Reserved
7
8Permission to use, copy, modify, and distribute this software and
9its documentation for any purpose and without fee is hereby
10granted, provided that the above copyright notice appear in all
11copies and that both that the copyright notice and this
12permission notice and warranty disclaimer appear in supporting
13documentation, and that the name of Lucent or any of its entities
14not be used in advertising or publicity pertaining to
15distribution of the software without specific, written prior
16permission.
17
18LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
19INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
20IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
21SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
22WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
23IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
24ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
25THIS 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
53typedef unsigned Long ULong;
54#endif
55#ifndef UShort
56typedef unsigned short UShort;
57#endif
58
59enum { /* 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
79typedef struct
80FPI {
81 int nbits;
82 int emin;
83 int emax;
84 int rounding;
85 int sudden_underflow;
86 int int_max;
87} FPI;
88
89enum { /* 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
97extern "C" {
98#endif
99
100extern char* __dtoa (double d, int mode, int ndigits, int *decpt,
101 int *sign, char **rve);
102extern char* __gdtoa (const FPI *fpi, int be, ULong *bits, int *kindp,
103 int mode, int ndigits, int *decpt, char **rve);
104extern void __freedtoa (char *);
105
106extern float __strtof (const char *, char **);
107extern double __strtod (const char *, char **);
108extern long double __strtold (const char *, char **);
109extern int __strtodg (const char *, char **, FPI *, Long *, ULong *);
110
111extern char* __g__fmt (char*, char*, char*, int, ULong, size_t);
112extern char* __g_dfmt (char*, double*, int, size_t);
113extern char* __g_ffmt (char*, float*, int, size_t);
114extern char* __g_xfmt (char*, void*, int, size_t);
115
116#ifdef __cplusplus
117}
118#endif
119#endif /* GDTOA_H_INCLUDED */