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