1112158Sdas/**************************************************************** 2112158Sdas 3112158SdasThe author of this software is David M. Gay. 4112158Sdas 5112158SdasCopyright (C) 1998 by Lucent Technologies 6112158SdasAll Rights Reserved 7112158Sdas 8112158SdasPermission to use, copy, modify, and distribute this software and 9112158Sdasits documentation for any purpose and without fee is hereby 10112158Sdasgranted, provided that the above copyright notice appear in all 11112158Sdascopies and that both that the copyright notice and this 12112158Sdaspermission notice and warranty disclaimer appear in supporting 13112158Sdasdocumentation, and that the name of Lucent or any of its entities 14112158Sdasnot be used in advertising or publicity pertaining to 15112158Sdasdistribution of the software without specific, written prior 16112158Sdaspermission. 17112158Sdas 18112158SdasLUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 19112158SdasINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. 20112158SdasIN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY 21112158SdasSPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 22112158SdasWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 23112158SdasIN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 24112158SdasARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 25112158SdasTHIS SOFTWARE. 26112158Sdas 27112158Sdas****************************************************************/ 28112158Sdas 29165743Sdas/* Please send bug reports to David M. Gay (dmg at acm dot org, 30165743Sdas * with " at " changed at "@" and " dot " changed to "."). */ 31112158Sdas 32112158Sdas#ifndef GDTOA_H_INCLUDED 33112158Sdas#define GDTOA_H_INCLUDED 34112158Sdas 35112158Sdas#include "arith.h" 36187808Sdas#include <stddef.h> /* for size_t */ 37112158Sdas 38112158Sdas#ifndef Long 39219557Sdas#define Long int 40112158Sdas#endif 41112158Sdas#ifndef ULong 42112158Sdastypedef unsigned Long ULong; 43112158Sdas#endif 44112158Sdas#ifndef UShort 45112158Sdastypedef unsigned short UShort; 46112158Sdas#endif 47112158Sdas 48112158Sdas#ifndef ANSI 49112158Sdas#ifdef KR_headers 50112158Sdas#define ANSI(x) () 51112158Sdas#define Void /*nothing*/ 52112158Sdas#else 53112158Sdas#define ANSI(x) x 54112158Sdas#define Void void 55112158Sdas#endif 56112158Sdas#endif /* ANSI */ 57112158Sdas 58112158Sdas#ifndef CONST 59112158Sdas#ifdef KR_headers 60112158Sdas#define CONST /* blank */ 61112158Sdas#else 62112158Sdas#define CONST const 63112158Sdas#endif 64112158Sdas#endif /* CONST */ 65112158Sdas 66112158Sdas enum { /* return values from strtodg */ 67112158Sdas STRTOG_Zero = 0, 68112158Sdas STRTOG_Normal = 1, 69112158Sdas STRTOG_Denormal = 2, 70112158Sdas STRTOG_Infinite = 3, 71112158Sdas STRTOG_NaN = 4, 72112158Sdas STRTOG_NaNbits = 5, 73112158Sdas STRTOG_NoNumber = 6, 74112158Sdas STRTOG_Retmask = 7, 75112158Sdas 76112158Sdas /* The following may be or-ed into one of the above values. */ 77112158Sdas 78182709Sdas STRTOG_Neg = 0x08, /* does not affect STRTOG_Inexlo or STRTOG_Inexhi */ 79182709Sdas STRTOG_Inexlo = 0x10, /* returned result rounded toward zero */ 80182709Sdas STRTOG_Inexhi = 0x20, /* returned result rounded away from zero */ 81112158Sdas STRTOG_Inexact = 0x30, 82112158Sdas STRTOG_Underflow= 0x40, 83112158Sdas STRTOG_Overflow = 0x80 84112158Sdas }; 85112158Sdas 86112158Sdas typedef struct 87112158SdasFPI { 88112158Sdas int nbits; 89112158Sdas int emin; 90112158Sdas int emax; 91112158Sdas int rounding; 92112158Sdas int sudden_underflow; 93112158Sdas } FPI; 94112158Sdas 95112158Sdasenum { /* FPI.rounding values: same as FLT_ROUNDS */ 96112158Sdas FPI_Round_zero = 0, 97112158Sdas FPI_Round_near = 1, 98112158Sdas FPI_Round_up = 2, 99112158Sdas FPI_Round_down = 3 100112158Sdas }; 101112158Sdas 102112158Sdas#ifdef __cplusplus 103112158Sdasextern "C" { 104112158Sdas#endif 105112158Sdas 106112158Sdasextern char* dtoa ANSI((double d, int mode, int ndigits, int *decpt, 107112158Sdas int *sign, char **rve)); 108112158Sdasextern char* gdtoa ANSI((FPI *fpi, int be, ULong *bits, int *kindp, 109112158Sdas int mode, int ndigits, int *decpt, char **rve)); 110112158Sdasextern void freedtoa ANSI((char*)); 111112158Sdasextern float strtof ANSI((CONST char *, char **)); 112112158Sdasextern double strtod ANSI((CONST char *, char **)); 113112158Sdasextern int strtodg ANSI((CONST char*, char**, FPI*, Long*, ULong*)); 114112158Sdas 115187808Sdasextern char* g_ddfmt ANSI((char*, double*, int, size_t)); 116187808Sdasextern char* g_dfmt ANSI((char*, double*, int, size_t)); 117187808Sdasextern char* g_ffmt ANSI((char*, float*, int, size_t)); 118187808Sdasextern char* g_Qfmt ANSI((char*, void*, int, size_t)); 119187808Sdasextern char* g_xfmt ANSI((char*, void*, int, size_t)); 120187808Sdasextern char* g_xLfmt ANSI((char*, void*, int, size_t)); 121112158Sdas 122112158Sdasextern int strtoId ANSI((CONST char*, char**, double*, double*)); 123112158Sdasextern int strtoIdd ANSI((CONST char*, char**, double*, double*)); 124112158Sdasextern int strtoIf ANSI((CONST char*, char**, float*, float*)); 125112158Sdasextern int strtoIQ ANSI((CONST char*, char**, void*, void*)); 126112158Sdasextern int strtoIx ANSI((CONST char*, char**, void*, void*)); 127112158Sdasextern int strtoIxL ANSI((CONST char*, char**, void*, void*)); 128112158Sdasextern int strtord ANSI((CONST char*, char**, int, double*)); 129112158Sdasextern int strtordd ANSI((CONST char*, char**, int, double*)); 130112158Sdasextern int strtorf ANSI((CONST char*, char**, int, float*)); 131112158Sdasextern int strtorQ ANSI((CONST char*, char**, int, void*)); 132112158Sdasextern int strtorx ANSI((CONST char*, char**, int, void*)); 133112158Sdasextern int strtorxL ANSI((CONST char*, char**, int, void*)); 134112158Sdas#if 1 135112158Sdasextern int strtodI ANSI((CONST char*, char**, double*)); 136112158Sdasextern int strtopd ANSI((CONST char*, char**, double*)); 137112158Sdasextern int strtopdd ANSI((CONST char*, char**, double*)); 138112158Sdasextern int strtopf ANSI((CONST char*, char**, float*)); 139112158Sdasextern int strtopQ ANSI((CONST char*, char**, void*)); 140112158Sdasextern int strtopx ANSI((CONST char*, char**, void*)); 141112158Sdasextern int strtopxL ANSI((CONST char*, char**, void*)); 142112158Sdas#else 143112158Sdas#define strtopd(s,se,x) strtord(s,se,1,x) 144112158Sdas#define strtopdd(s,se,x) strtordd(s,se,1,x) 145112158Sdas#define strtopf(s,se,x) strtorf(s,se,1,x) 146112158Sdas#define strtopQ(s,se,x) strtorQ(s,se,1,x) 147112158Sdas#define strtopx(s,se,x) strtorx(s,se,1,x) 148112158Sdas#define strtopxL(s,se,x) strtorxL(s,se,1,x) 149112158Sdas#endif 150112158Sdas 151112158Sdas#ifdef __cplusplus 152112158Sdas} 153112158Sdas#endif 154112158Sdas#endif /* GDTOA_H_INCLUDED */ 155