Home | History | Annotate | Line # | Download | only in gdtoa
gdtoa.h revision 1.9
      1  1.9  christos /* $NetBSD: gdtoa.h,v 1.9 2011/03/20 23:15:35 christos 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.9  christos #include <stddef.h> /* for size_t */
     39  1.9  christos #include <stdint.h>
     40  1.1    kleink 
     41  1.1    kleink #ifndef Long
     42  1.6  christos #define Long int32_t
     43  1.1    kleink #endif
     44  1.1    kleink #ifndef ULong
     45  1.6  christos #define ULong uint32_t
     46  1.1    kleink #endif
     47  1.1    kleink #ifndef UShort
     48  1.6  christos #define UShort uint16_t
     49  1.1    kleink #endif
     50  1.1    kleink 
     51  1.1    kleink #ifndef ANSI
     52  1.1    kleink #ifdef KR_headers
     53  1.1    kleink #define ANSI(x) ()
     54  1.1    kleink #define Void /*nothing*/
     55  1.1    kleink #else
     56  1.1    kleink #define ANSI(x) x
     57  1.1    kleink #define Void void
     58  1.1    kleink #endif
     59  1.1    kleink #endif /* ANSI */
     60  1.1    kleink 
     61  1.1    kleink #ifndef CONST
     62  1.1    kleink #ifdef KR_headers
     63  1.1    kleink #define CONST /* blank */
     64  1.1    kleink #else
     65  1.1    kleink #define CONST const
     66  1.1    kleink #endif
     67  1.1    kleink #endif /* CONST */
     68  1.1    kleink 
     69  1.1    kleink  enum {	/* return values from strtodg */
     70  1.1    kleink 	STRTOG_Zero	= 0,
     71  1.1    kleink 	STRTOG_Normal	= 1,
     72  1.1    kleink 	STRTOG_Denormal	= 2,
     73  1.1    kleink 	STRTOG_Infinite	= 3,
     74  1.1    kleink 	STRTOG_NaN	= 4,
     75  1.1    kleink 	STRTOG_NaNbits	= 5,
     76  1.1    kleink 	STRTOG_NoNumber	= 6,
     77  1.1    kleink 	STRTOG_Retmask	= 7,
     78  1.1    kleink 
     79  1.1    kleink 	/* The following may be or-ed into one of the above values. */
     80  1.1    kleink 
     81  1.9  christos 	STRTOG_Neg	= 0x08, /* does not affect STRTOG_Inexlo or STRTOG_Inexhi */
     82  1.9  christos 	STRTOG_Inexlo	= 0x10,	/* returned result rounded toward zero */
     83  1.9  christos 	STRTOG_Inexhi	= 0x20, /* returned result rounded away from zero */
     84  1.1    kleink 	STRTOG_Inexact	= 0x30,
     85  1.1    kleink 	STRTOG_Underflow= 0x40,
     86  1.8  christos 	STRTOG_Overflow	= 0x80,
     87  1.8  christos 	STRTOG_NoMemory = 0x100
     88  1.1    kleink 	};
     89  1.1    kleink 
     90  1.1    kleink  typedef struct
     91  1.1    kleink FPI {
     92  1.1    kleink 	int nbits;
     93  1.1    kleink 	int emin;
     94  1.1    kleink 	int emax;
     95  1.1    kleink 	int rounding;
     96  1.1    kleink 	int sudden_underflow;
     97  1.1    kleink 	} FPI;
     98  1.1    kleink 
     99  1.1    kleink enum {	/* FPI.rounding values: same as FLT_ROUNDS */
    100  1.1    kleink 	FPI_Round_zero = 0,
    101  1.1    kleink 	FPI_Round_near = 1,
    102  1.1    kleink 	FPI_Round_up = 2,
    103  1.1    kleink 	FPI_Round_down = 3
    104  1.1    kleink 	};
    105  1.1    kleink 
    106  1.1    kleink #ifdef __cplusplus
    107  1.1    kleink extern "C" {
    108  1.1    kleink #endif
    109  1.1    kleink 
    110  1.2    kleink #define	dtoa		__dtoa
    111  1.7  christos #define	gdtoa		__gdtoa
    112  1.7  christos #define	ldtoa		__ldtoa
    113  1.7  christos #define	hldtoa		__hldtoa
    114  1.7  christos #define	hdtoa		__hdtoa
    115  1.2    kleink #define	freedtoa	__freedtoa
    116  1.3    kleink #define	strtodg		__strtodg_D2A
    117  1.5    kleink #define	strtopQ		__strtopQ_D2A
    118  1.5    kleink #define	strtopx		__strtopx_D2A
    119  1.5    kleink #define	strtopxL	__strtopxL_D2A
    120  1.2    kleink #define	strtord		__strtord_D2A
    121  1.2    kleink 
    122  1.1    kleink extern char* dtoa  ANSI((double d, int mode, int ndigits, int *decpt,
    123  1.1    kleink 			int *sign, char **rve));
    124  1.7  christos extern char* hdtoa ANSI((double d, const char *xdigs, int ndigits, int *decpt,
    125  1.7  christos 			int *sign, char **rve));
    126  1.7  christos extern char* ldtoa ANSI((long double *ld, int mode, int ndigits, int *decpt,
    127  1.7  christos 			int *sign, char **rve));
    128  1.7  christos extern char* hldtoa ANSI((long double e, const char *xdigs, int ndigits,
    129  1.7  christos 			int *decpt, int *sign, char **rve));
    130  1.7  christos 
    131  1.1    kleink extern char* gdtoa ANSI((FPI *fpi, int be, ULong *bits, int *kindp,
    132  1.1    kleink 			int mode, int ndigits, int *decpt, char **rve));
    133  1.1    kleink extern void freedtoa ANSI((char*));
    134  1.1    kleink extern float  strtof ANSI((CONST char *, char **));
    135  1.1    kleink extern double strtod ANSI((CONST char *, char **));
    136  1.4    kleink extern int strtodg ANSI((CONST char*, char**, CONST FPI*, Long*, ULong*));
    137  1.1    kleink 
    138  1.9  christos extern char*	g_ddfmt  ANSI((char*, double*, int, size_t));
    139  1.9  christos extern char*	g_dfmt   ANSI((char*, double*, int, size_t));
    140  1.9  christos extern char*	g_ffmt   ANSI((char*, float*,  int, size_t));
    141  1.9  christos extern char*	g_Qfmt   ANSI((char*, void*,   int, size_t));
    142  1.9  christos extern char*	g_xfmt   ANSI((char*, void*,   int, size_t));
    143  1.9  christos extern char*	g_xLfmt  ANSI((char*, void*,   int, size_t));
    144  1.1    kleink 
    145  1.1    kleink extern int	strtoId  ANSI((CONST char*, char**, double*, double*));
    146  1.1    kleink extern int	strtoIdd ANSI((CONST char*, char**, double*, double*));
    147  1.1    kleink extern int	strtoIf  ANSI((CONST char*, char**, float*, float*));
    148  1.1    kleink extern int	strtoIQ  ANSI((CONST char*, char**, void*, void*));
    149  1.1    kleink extern int	strtoIx  ANSI((CONST char*, char**, void*, void*));
    150  1.1    kleink extern int	strtoIxL ANSI((CONST char*, char**, void*, void*));
    151  1.1    kleink extern int	strtord  ANSI((CONST char*, char**, int, double*));
    152  1.1    kleink extern int	strtordd ANSI((CONST char*, char**, int, double*));
    153  1.1    kleink extern int	strtorf  ANSI((CONST char*, char**, int, float*));
    154  1.1    kleink extern int	strtorQ  ANSI((CONST char*, char**, int, void*));
    155  1.1    kleink extern int	strtorx  ANSI((CONST char*, char**, int, void*));
    156  1.1    kleink extern int	strtorxL ANSI((CONST char*, char**, int, void*));
    157  1.1    kleink #if 1
    158  1.1    kleink extern int	strtodI  ANSI((CONST char*, char**, double*));
    159  1.1    kleink extern int	strtopd  ANSI((CONST char*, char**, double*));
    160  1.1    kleink extern int	strtopdd ANSI((CONST char*, char**, double*));
    161  1.1    kleink extern int	strtopf  ANSI((CONST char*, char**, float*));
    162  1.1    kleink extern int	strtopQ  ANSI((CONST char*, char**, void*));
    163  1.1    kleink extern int	strtopx  ANSI((CONST char*, char**, void*));
    164  1.1    kleink extern int	strtopxL ANSI((CONST char*, char**, void*));
    165  1.1    kleink #else
    166  1.1    kleink #define strtopd(s,se,x) strtord(s,se,1,x)
    167  1.1    kleink #define strtopdd(s,se,x) strtordd(s,se,1,x)
    168  1.1    kleink #define strtopf(s,se,x) strtorf(s,se,1,x)
    169  1.1    kleink #define strtopQ(s,se,x) strtorQ(s,se,1,x)
    170  1.1    kleink #define strtopx(s,se,x) strtorx(s,se,1,x)
    171  1.1    kleink #define strtopxL(s,se,x) strtorxL(s,se,1,x)
    172  1.1    kleink #endif
    173  1.1    kleink 
    174  1.1    kleink #ifdef __cplusplus
    175  1.1    kleink }
    176  1.1    kleink #endif
    177  1.1    kleink #endif /* GDTOA_H_INCLUDED */
    178