gdtoa.h revision 219557
1836Sattila/**************************************************************** 2836Sattila 3836SattilaThe author of this software is David M. Gay. 4877Sattila 5836SattilaCopyright (C) 1998 by Lucent Technologies 6836SattilaAll Rights Reserved 7836Sattila 8877SattilaPermission to use, copy, modify, and distribute this software and 9836Sattilaits documentation for any purpose and without fee is hereby 10836Sattilagranted, provided that the above copyright notice appear in all 11836Sattilacopies and that both that the copyright notice and this 12836Sattilapermission notice and warranty disclaimer appear in supporting 13836Sattiladocumentation, and that the name of Lucent or any of its entities 14877Sattilanot be used in advertising or publicity pertaining to 15836Sattiladistribution of the software without specific, written prior 16836Sattilapermission. 17836Sattila 18877SattilaLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 19836SattilaINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. 20836SattilaIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY 21836SattilaSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 22836SattilaWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 23836SattilaIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 24836SattilaARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 25836SattilaTHIS SOFTWARE. 26836Sattila 27836Sattila****************************************************************/ 28836Sattila 29836Sattila/* Please send bug reports to David M. Gay (dmg at acm dot org, 30836Sattila * with " at " changed at "@" and " dot " changed to "."). */ 31836Sattila 32836Sattila#ifndef GDTOA_H_INCLUDED 33836Sattila#define GDTOA_H_INCLUDED 34836Sattila 35836Sattila#include "arith.h" 36836Sattila#include <stddef.h> /* for size_t */ 37836Sattila 38836Sattila#ifndef Long 39836Sattila#define Long int 40836Sattila#endif 41836Sattila#ifndef ULong 42836Sattilatypedef unsigned Long ULong; 43836Sattila#endif 44836Sattila#ifndef UShort 45836Sattilatypedef unsigned short UShort; 46836Sattila#endif 47836Sattila 48836Sattila#ifndef ANSI 49836Sattila#ifdef KR_headers 50836Sattila#define ANSI(x) () 51836Sattila#define Void /*nothing*/ 52836Sattila#else 53836Sattila#define ANSI(x) x 54836Sattila#define Void void 55836Sattila#endif 56836Sattila#endif /* ANSI */ 57836Sattila 58836Sattila#ifndef CONST 59836Sattila#ifdef KR_headers 60836Sattila#define CONST /* blank */ 61836Sattila#else 62836Sattila#define CONST const 63836Sattila#endif 64836Sattila#endif /* CONST */ 65836Sattila 66836Sattila enum { /* return values from strtodg */ 67836Sattila STRTOG_Zero = 0, 68836Sattila STRTOG_Normal = 1, 69836Sattila STRTOG_Denormal = 2, 70836Sattila STRTOG_Infinite = 3, 71836Sattila STRTOG_NaN = 4, 72836Sattila STRTOG_NaNbits = 5, 73836Sattila STRTOG_NoNumber = 6, 74836Sattila STRTOG_Retmask = 7, 75836Sattila 76836Sattila /* The following may be or-ed into one of the above values. */ 77836Sattila 78836Sattila STRTOG_Neg = 0x08, /* does not affect STRTOG_Inexlo or STRTOG_Inexhi */ 79836Sattila STRTOG_Inexlo = 0x10, /* returned result rounded toward zero */ 80836Sattila STRTOG_Inexhi = 0x20, /* returned result rounded away from zero */ 81836Sattila STRTOG_Inexact = 0x30, 82836Sattila STRTOG_Underflow= 0x40, 83836Sattila STRTOG_Overflow = 0x80 84836Sattila }; 85836Sattila 86836Sattila typedef struct 87836SattilaFPI { 88836Sattila int nbits; 89836Sattila int emin; 90836Sattila int emax; 91836Sattila int rounding; 92836Sattila int sudden_underflow; 93836Sattila } FPI; 94836Sattila 95836Sattilaenum { /* FPI.rounding values: same as FLT_ROUNDS */ 96836Sattila FPI_Round_zero = 0, 97836Sattila FPI_Round_near = 1, 98836Sattila FPI_Round_up = 2, 99836Sattila FPI_Round_down = 3 100836Sattila }; 101 102#ifdef __cplusplus 103extern "C" { 104#endif 105 106extern char* dtoa ANSI((double d, int mode, int ndigits, int *decpt, 107 int *sign, char **rve)); 108extern char* gdtoa ANSI((FPI *fpi, int be, ULong *bits, int *kindp, 109 int mode, int ndigits, int *decpt, char **rve)); 110extern void freedtoa ANSI((char*)); 111extern float strtof ANSI((CONST char *, char **)); 112extern double strtod ANSI((CONST char *, char **)); 113extern int strtodg ANSI((CONST char*, char**, FPI*, Long*, ULong*)); 114 115extern char* g_ddfmt ANSI((char*, double*, int, size_t)); 116extern char* g_dfmt ANSI((char*, double*, int, size_t)); 117extern char* g_ffmt ANSI((char*, float*, int, size_t)); 118extern char* g_Qfmt ANSI((char*, void*, int, size_t)); 119extern char* g_xfmt ANSI((char*, void*, int, size_t)); 120extern char* g_xLfmt ANSI((char*, void*, int, size_t)); 121 122extern int strtoId ANSI((CONST char*, char**, double*, double*)); 123extern int strtoIdd ANSI((CONST char*, char**, double*, double*)); 124extern int strtoIf ANSI((CONST char*, char**, float*, float*)); 125extern int strtoIQ ANSI((CONST char*, char**, void*, void*)); 126extern int strtoIx ANSI((CONST char*, char**, void*, void*)); 127extern int strtoIxL ANSI((CONST char*, char**, void*, void*)); 128extern int strtord ANSI((CONST char*, char**, int, double*)); 129extern int strtordd ANSI((CONST char*, char**, int, double*)); 130extern int strtorf ANSI((CONST char*, char**, int, float*)); 131extern int strtorQ ANSI((CONST char*, char**, int, void*)); 132extern int strtorx ANSI((CONST char*, char**, int, void*)); 133extern int strtorxL ANSI((CONST char*, char**, int, void*)); 134#if 1 135extern int strtodI ANSI((CONST char*, char**, double*)); 136extern int strtopd ANSI((CONST char*, char**, double*)); 137extern int strtopdd ANSI((CONST char*, char**, double*)); 138extern int strtopf ANSI((CONST char*, char**, float*)); 139extern int strtopQ ANSI((CONST char*, char**, void*)); 140extern int strtopx ANSI((CONST char*, char**, void*)); 141extern int strtopxL ANSI((CONST char*, char**, void*)); 142#else 143#define strtopd(s,se,x) strtord(s,se,1,x) 144#define strtopdd(s,se,x) strtordd(s,se,1,x) 145#define strtopf(s,se,x) strtorf(s,se,1,x) 146#define strtopQ(s,se,x) strtorQ(s,se,1,x) 147#define strtopx(s,se,x) strtorx(s,se,1,x) 148#define strtopxL(s,se,x) strtorxL(s,se,1,x) 149#endif 150 151#ifdef __cplusplus 152} 153#endif 154#endif /* GDTOA_H_INCLUDED */ 155