/****************************************************************12The author of this software is David M. Gay.34Copyright (C) 1998-2000 by Lucent Technologies5All Rights Reserved67Permission to use, copy, modify, and distribute this software and8its documentation for any purpose and without fee is hereby9granted, provided that the above copyright notice appear in all10copies and that both that the copyright notice and this11permission notice and warranty disclaimer appear in supporting12documentation, and that the name of Lucent or any of its entities13not be used in advertising or publicity pertaining to14distribution of the software without specific, written prior15permission.1617LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,18INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.19IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY20SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES21WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER22IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,23ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF24THIS SOFTWARE.2526****************************************************************/2728/* $FreeBSD$ */2930/* This is a variation on dtoa.c that converts arbitary binary31floating-point formats to and from decimal notation. It uses32double-precision arithmetic internally, so there are still33various #ifdefs that adapt the calculations to the native34double-precision arithmetic (any of IEEE, VAX D_floating,35or IBM mainframe arithmetic).3637Please send bug reports to David M. Gay (dmg at acm dot org,38with " at " changed at "@" and " dot " changed to ".").39*/4041/* On a machine with IEEE extended-precision registers, it is42* necessary to specify double-precision (53-bit) rounding precision43* before invoking strtod or dtoa. If the machine uses (the equivalent44* of) Intel 80x87 arithmetic, the call45* _control87(PC_53, MCW_PC);46* does this with many compilers. Whether this or another call is47* appropriate depends on the compiler; for this to work, it may be48* necessary to #include "float.h" or another system-dependent header49* file.50*/5152/* strtod for IEEE-, VAX-, and IBM-arithmetic machines.53*54* This strtod returns a nearest machine number to the input decimal55* string (or sets errno to ERANGE). With IEEE arithmetic, ties are56* broken by the IEEE round-even rule. Otherwise ties are broken by57* biased rounding (add half and chop).58*59* Inspired loosely by William D. Clinger's paper "How to Read Floating60* Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 112-126].61*62* Modifications:63*64* 1. We only require IEEE, IBM, or VAX double-precision65* arithmetic (not IEEE double-extended).66* 2. We get by with floating-point arithmetic in a case that67* Clinger missed -- when we're computing d * 10^n68* for a small integer d and the integer n is not too69* much larger than 22 (the maximum integer k for which70* we can represent 10^k exactly), we may be able to71* compute (d*10^k) * 10^(e-k) with just one roundoff.72* 3. Rather than a bit-at-a-time adjustment of the binary73* result in the hard case, we use floating-point74* arithmetic to determine the adjustment to within75* one bit; only in really hard cases do we need to76* compute a second residual.77* 4. Because of 3., we don't need a large table of powers of 1078* for ten-to-e (just some small tables, e.g. of 10^k79* for 0 <= k <= 22).80*/8182/*83* #define IEEE_8087 for IEEE-arithmetic machines where the least84* significant byte has the lowest address.85* #define IEEE_MC68k for IEEE-arithmetic machines where the most86* significant byte has the lowest address.87* #define Long int on machines with 32-bit ints and 64-bit longs.88* #define Sudden_Underflow for IEEE-format machines without gradual89* underflow (i.e., that flush to zero on underflow).90* #define IBM for IBM mainframe-style floating-point arithmetic.91* #define VAX for VAX-style floating-point arithmetic (D_floating).92* #define No_leftright to omit left-right logic in fast floating-point93* computation of dtoa.94* #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3.95* #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines96* that use extended-precision instructions to compute rounded97* products and quotients) with IBM.98* #define ROUND_BIASED for IEEE-format with biased rounding and arithmetic99* that rounds toward +Infinity.100* #define ROUND_BIASED_without_Round_Up for IEEE-format with biased101* rounding when the underlying floating-point arithmetic uses102* unbiased rounding. This prevent using ordinary floating-point103* arithmetic when the result could be computed with one rounding error.104* #define Inaccurate_Divide for IEEE-format with correctly rounded105* products but inaccurate quotients, e.g., for Intel i860.106* #define NO_LONG_LONG on machines that do not have a "long long"107* integer type (of >= 64 bits). On such machines, you can108* #define Just_16 to store 16 bits per 32-bit Long when doing109* high-precision integer arithmetic. Whether this speeds things110* up or slows things down depends on the machine and the number111* being converted. If long long is available and the name is112* something other than "long long", #define Llong to be the name,113* and if "unsigned Llong" does not work as an unsigned version of114* Llong, #define #ULLong to be the corresponding unsigned type.115* #define KR_headers for old-style C function headers.116* #define Bad_float_h if your system lacks a float.h or if it does not117* define some or all of DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP,118* FLT_RADIX, FLT_ROUNDS, and DBL_MAX.119* #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n)120* if memory is available and otherwise does something you deem121* appropriate. If MALLOC is undefined, malloc will be invoked122* directly -- and assumed always to succeed. Similarly, if you123* want something other than the system's free() to be called to124* recycle memory acquired from MALLOC, #define FREE to be the125* name of the alternate routine. (FREE or free is only called in126* pathological cases, e.g., in a gdtoa call after a gdtoa return in127* mode 3 with thousands of digits requested.)128* #define Omit_Private_Memory to omit logic (added Jan. 1998) for making129* memory allocations from a private pool of memory when possible.130* When used, the private pool is PRIVATE_MEM bytes long: 2304 bytes,131* unless #defined to be a different length. This default length132* suffices to get rid of MALLOC calls except for unusual cases,133* such as decimal-to-binary conversion of a very long string of134* digits. When converting IEEE double precision values, the135* longest string gdtoa can return is about 751 bytes long. For136* conversions by strtod of strings of 800 digits and all gdtoa137* conversions of IEEE doubles in single-threaded executions with138* 8-byte pointers, PRIVATE_MEM >= 7400 appears to suffice; with139* 4-byte pointers, PRIVATE_MEM >= 7112 appears adequate.140* #define NO_INFNAN_CHECK if you do not wish to have INFNAN_CHECK141* #defined automatically on IEEE systems. On such systems,142* when INFNAN_CHECK is #defined, strtod checks143* for Infinity and NaN (case insensitively).144* When INFNAN_CHECK is #defined and No_Hex_NaN is not #defined,145* strtodg also accepts (case insensitively) strings of the form146* NaN(x), where x is a string of hexadecimal digits (optionally147* preceded by 0x or 0X) and spaces; if there is only one string148* of hexadecimal digits, it is taken for the fraction bits of the149* resulting NaN; if there are two or more strings of hexadecimal150* digits, each string is assigned to the next available sequence151* of 32-bit words of fractions bits (starting with the most152* significant), right-aligned in each sequence.153* Unless GDTOA_NON_PEDANTIC_NANCHECK is #defined, input "NaN(...)"154* is consumed even when ... has the wrong form (in which case the155* "(...)" is consumed but ignored).156* #define MULTIPLE_THREADS if the system offers preemptively scheduled157* multiple threads. In this case, you must provide (or suitably158* #define) two locks, acquired by ACQUIRE_DTOA_LOCK(n) and freed159* by FREE_DTOA_LOCK(n) for n = 0 or 1. (The second lock, accessed160* in pow5mult, ensures lazy evaluation of only one copy of high161* powers of 5; omitting this lock would introduce a small162* probability of wasting memory, but would otherwise be harmless.)163* You must also invoke freedtoa(s) to free the value s returned by164* dtoa. You may do so whether or not MULTIPLE_THREADS is #defined.165* #define IMPRECISE_INEXACT if you do not care about the setting of166* the STRTOG_Inexact bits in the special case of doing IEEE double167* precision conversions (which could also be done by the strtod in168* dtoa.c).169* #define NO_HEX_FP to disable recognition of C9x's hexadecimal170* floating-point constants.171* #define -DNO_ERRNO to suppress setting errno (in strtod.c and172* strtodg.c).173* #define NO_STRING_H to use private versions of memcpy.174* On some K&R systems, it may also be necessary to175* #define DECLARE_SIZE_T in this case.176* #define USE_LOCALE to use the current locale's decimal_point value.177*/178179#ifndef GDTOAIMP_H_INCLUDED180#define GDTOAIMP_H_INCLUDED181182#define Long int183184#include "gdtoa.h"185#include "gd_qnan.h"186#ifdef Honor_FLT_ROUNDS187#include <fenv.h>188#endif189190#ifdef DEBUG191#include "stdio.h"192#define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);}193#endif194195#include "limits.h"196#include "stdlib.h"197#include "string.h"198#include "libc_private.h"199200#include "namespace.h"201#include <pthread.h>202#include "un-namespace.h"203#include "xlocale_private.h"204205#ifdef KR_headers206#define Char char207#else208#define Char void209#endif210211#ifdef MALLOC212extern Char *MALLOC ANSI((size_t));213#else214#define MALLOC malloc215#endif216217#define INFNAN_CHECK218#define USE_LOCALE219#define NO_LOCALE_CACHE220#define Honor_FLT_ROUNDS221#define Trust_FLT_ROUNDS222223#undef IEEE_Arith224#undef Avoid_Underflow225#ifdef IEEE_MC68k226#define IEEE_Arith227#endif228#ifdef IEEE_8087229#define IEEE_Arith230#endif231232#include "errno.h"233#ifdef Bad_float_h234235#ifdef IEEE_Arith236#define DBL_DIG 15237#define DBL_MAX_10_EXP 308238#define DBL_MAX_EXP 1024239#define FLT_RADIX 2240#define DBL_MAX 1.7976931348623157e+308241#endif242243#ifdef IBM244#define DBL_DIG 16245#define DBL_MAX_10_EXP 75246#define DBL_MAX_EXP 63247#define FLT_RADIX 16248#define DBL_MAX 7.2370055773322621e+75249#endif250251#ifdef VAX252#define DBL_DIG 16253#define DBL_MAX_10_EXP 38254#define DBL_MAX_EXP 127255#define FLT_RADIX 2256#define DBL_MAX 1.7014118346046923e+38257#define n_bigtens 2258#endif259260#ifndef LONG_MAX261#define LONG_MAX 2147483647262#endif263264#else /* ifndef Bad_float_h */265#include "float.h"266#endif /* Bad_float_h */267268#ifdef IEEE_Arith269#define Scale_Bit 0x10270#define n_bigtens 5271#endif272273#ifdef IBM274#define n_bigtens 3275#endif276277#ifdef VAX278#define n_bigtens 2279#endif280281#ifndef __MATH_H__282#include "math.h"283#endif284285#ifdef __cplusplus286extern "C" {287#endif288289#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1290Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined.291#endif292293typedef union { double d; ULong L[2]; } U;294295#ifdef IEEE_8087296#define word0(x) (x)->L[1]297#define word1(x) (x)->L[0]298#else299#define word0(x) (x)->L[0]300#define word1(x) (x)->L[1]301#endif302#define dval(x) (x)->d303304/* The following definition of Storeinc is appropriate for MIPS processors.305* An alternative that might be better on some machines is306* #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff)307*/308#if defined(IEEE_8087) + defined(VAX)309#define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \310((unsigned short *)a)[0] = (unsigned short)c, a++)311#else312#define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \313((unsigned short *)a)[1] = (unsigned short)c, a++)314#endif315316/* #define P DBL_MANT_DIG */317/* Ten_pmax = floor(P*log(2)/log(5)) */318/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */319/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */320/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */321322#ifdef IEEE_Arith323#define Exp_shift 20324#define Exp_shift1 20325#define Exp_msk1 0x100000326#define Exp_msk11 0x100000327#define Exp_mask 0x7ff00000328#define P 53329#define Bias 1023330#define Emin (-1022)331#define Exp_1 0x3ff00000332#define Exp_11 0x3ff00000333#define Ebits 11334#define Frac_mask 0xfffff335#define Frac_mask1 0xfffff336#define Ten_pmax 22337#define Bletch 0x10338#define Bndry_mask 0xfffff339#define Bndry_mask1 0xfffff340#define LSB 1341#define Sign_bit 0x80000000342#define Log2P 1343#define Tiny0 0344#define Tiny1 1345#define Quick_max 14346#define Int_max 14347348#ifndef Flt_Rounds349#ifdef FLT_ROUNDS350#define Flt_Rounds FLT_ROUNDS351#else352#define Flt_Rounds 1353#endif354#endif /*Flt_Rounds*/355356#else /* ifndef IEEE_Arith */357#undef Sudden_Underflow358#define Sudden_Underflow359#ifdef IBM360#undef Flt_Rounds361#define Flt_Rounds 0362#define Exp_shift 24363#define Exp_shift1 24364#define Exp_msk1 0x1000000365#define Exp_msk11 0x1000000366#define Exp_mask 0x7f000000367#define P 14368#define Bias 65369#define Exp_1 0x41000000370#define Exp_11 0x41000000371#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */372#define Frac_mask 0xffffff373#define Frac_mask1 0xffffff374#define Bletch 4375#define Ten_pmax 22376#define Bndry_mask 0xefffff377#define Bndry_mask1 0xffffff378#define LSB 1379#define Sign_bit 0x80000000380#define Log2P 4381#define Tiny0 0x100000382#define Tiny1 0383#define Quick_max 14384#define Int_max 15385#else /* VAX */386#undef Flt_Rounds387#define Flt_Rounds 1388#define Exp_shift 23389#define Exp_shift1 7390#define Exp_msk1 0x80391#define Exp_msk11 0x800000392#define Exp_mask 0x7f80393#define P 56394#define Bias 129395#define Exp_1 0x40800000396#define Exp_11 0x4080397#define Ebits 8398#define Frac_mask 0x7fffff399#define Frac_mask1 0xffff007f400#define Ten_pmax 24401#define Bletch 2402#define Bndry_mask 0xffff007f403#define Bndry_mask1 0xffff007f404#define LSB 0x10000405#define Sign_bit 0x8000406#define Log2P 1407#define Tiny0 0x80408#define Tiny1 0409#define Quick_max 15410#define Int_max 15411#endif /* IBM, VAX */412#endif /* IEEE_Arith */413414#ifndef IEEE_Arith415#define ROUND_BIASED416#else417#ifdef ROUND_BIASED_without_Round_Up418#undef ROUND_BIASED419#define ROUND_BIASED420#endif421#endif422423#ifdef RND_PRODQUOT424#define rounded_product(a,b) a = rnd_prod(a, b)425#define rounded_quotient(a,b) a = rnd_quot(a, b)426#ifdef KR_headers427extern double rnd_prod(), rnd_quot();428#else429extern double rnd_prod(double, double), rnd_quot(double, double);430#endif431#else432#define rounded_product(a,b) a *= b433#define rounded_quotient(a,b) a /= b434#endif435436#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1))437#define Big1 0xffffffff438439#undef Pack_16440#ifndef Pack_32441#define Pack_32442#endif443444#ifdef NO_LONG_LONG445#undef ULLong446#ifdef Just_16447#undef Pack_32448#define Pack_16449/* When Pack_32 is not defined, we store 16 bits per 32-bit Long.450* This makes some inner loops simpler and sometimes saves work451* during multiplications, but it often seems to make things slightly452* slower. Hence the default is now to store 32 bits per Long.453*/454#endif455#else /* long long available */456#ifndef Llong457#define Llong long long458#endif459#ifndef ULLong460#define ULLong unsigned Llong461#endif462#endif /* NO_LONG_LONG */463464#ifdef Pack_32465#define ULbits 32466#define kshift 5467#define kmask 31468#define ALL_ON 0xffffffff469#else470#define ULbits 16471#define kshift 4472#define kmask 15473#define ALL_ON 0xffff474#endif475476#define MULTIPLE_THREADS477extern pthread_mutex_t __gdtoa_locks[2];478#define ACQUIRE_DTOA_LOCK(n) do { \479if (__isthreaded) \480_pthread_mutex_lock(&__gdtoa_locks[n]); \481} while(0)482#define FREE_DTOA_LOCK(n) do { \483if (__isthreaded) \484_pthread_mutex_unlock(&__gdtoa_locks[n]); \485} while(0)486487#define Kmax 9488489struct490Bigint {491struct Bigint *next;492int k, maxwds, sign, wds;493ULong x[1];494};495496typedef struct Bigint Bigint;497498#ifdef NO_STRING_H499#ifdef DECLARE_SIZE_T500typedef unsigned int size_t;501#endif502extern void memcpy_D2A ANSI((void*, const void*, size_t));503#define Bcopy(x,y) memcpy_D2A(&x->sign,&y->sign,y->wds*sizeof(ULong) + 2*sizeof(int))504#else /* !NO_STRING_H */505#define Bcopy(x,y) memcpy(&x->sign,&y->sign,y->wds*sizeof(ULong) + 2*sizeof(int))506#endif /* NO_STRING_H */507508/*509* Paranoia: Protect exported symbols, including ones in files we don't510* compile right now. The standard strtof and strtod survive.511*/512#define dtoa __dtoa513#define gdtoa __gdtoa514#define freedtoa __freedtoa515#define strtodg __strtodg516#define g_ddfmt __g_ddfmt517#define g_dfmt __g_dfmt518#define g_ffmt __g_ffmt519#define g_Qfmt __g_Qfmt520#define g_xfmt __g_xfmt521#define g_xLfmt __g_xLfmt522#define strtoId __strtoId523#define strtoIdd __strtoIdd524#define strtoIf __strtoIf525#define strtoIQ __strtoIQ526#define strtoIx __strtoIx527#define strtoIxL __strtoIxL528#define strtord_l __strtord_l529#define strtordd __strtordd530#define strtorf __strtorf531#define strtorQ_l __strtorQ_l532#define strtorx_l __strtorx_l533#define strtorxL __strtorxL534#define strtodI __strtodI535#define strtopd __strtopd536#define strtopdd __strtopdd537#define strtopf __strtopf538#define strtopQ __strtopQ539#define strtopx __strtopx540#define strtopxL __strtopxL541542/* Protect gdtoa-internal symbols */543#define Balloc __Balloc_D2A544#define Bfree __Bfree_D2A545#define ULtoQ __ULtoQ_D2A546#define ULtof __ULtof_D2A547#define ULtod __ULtod_D2A548#define ULtodd __ULtodd_D2A549#define ULtox __ULtox_D2A550#define ULtoxL __ULtoxL_D2A551#define any_on __any_on_D2A552#define b2d __b2d_D2A553#define bigtens __bigtens_D2A554#define cmp __cmp_D2A555#define copybits __copybits_D2A556#define d2b __d2b_D2A557#define decrement __decrement_D2A558#define diff __diff_D2A559#define dtoa_result __dtoa_result_D2A560#define g__fmt __g__fmt_D2A561#define gethex __gethex_D2A562#define hexdig __hexdig_D2A563#define hexdig_init_D2A __hexdig_init_D2A564#define hexnan __hexnan_D2A565#define hi0bits __hi0bits_D2A566#define hi0bits_D2A __hi0bits_D2A567#define i2b __i2b_D2A568#define increment __increment_D2A569#define lo0bits __lo0bits_D2A570#define lshift __lshift_D2A571#define match __match_D2A572#define mult __mult_D2A573#define multadd __multadd_D2A574#define nrv_alloc __nrv_alloc_D2A575#define pow5mult __pow5mult_D2A576#define quorem __quorem_D2A577#define ratio __ratio_D2A578#define rshift __rshift_D2A579#define rv_alloc __rv_alloc_D2A580#define s2b __s2b_D2A581#define set_ones __set_ones_D2A582#define strcp __strcp_D2A583#define strcp_D2A __strcp_D2A584#define strtoIg __strtoIg_D2A585#define sum __sum_D2A586#define tens __tens_D2A587#define tinytens __tinytens_D2A588#define tinytens __tinytens_D2A589#define trailz __trailz_D2A590#define ulp __ulp_D2A591592extern char *dtoa_result;593extern CONST double bigtens[], tens[], tinytens[];594extern unsigned char hexdig[];595596extern Bigint *Balloc ANSI((int));597extern void Bfree ANSI((Bigint*));598extern void ULtof ANSI((ULong*, ULong*, Long, int));599extern void ULtod ANSI((ULong*, ULong*, Long, int));600extern void ULtodd ANSI((ULong*, ULong*, Long, int));601extern void ULtoQ ANSI((ULong*, ULong*, Long, int));602extern void ULtox ANSI((UShort*, ULong*, Long, int));603extern void ULtoxL ANSI((ULong*, ULong*, Long, int));604extern ULong any_on ANSI((Bigint*, int));605extern double b2d ANSI((Bigint*, int*));606extern int cmp ANSI((Bigint*, Bigint*));607extern void copybits ANSI((ULong*, int, Bigint*));608extern Bigint *d2b ANSI((double, int*, int*));609extern void decrement ANSI((Bigint*));610extern Bigint *diff ANSI((Bigint*, Bigint*));611extern char *dtoa ANSI((double d, int mode, int ndigits,612int *decpt, int *sign, char **rve));613extern void freedtoa ANSI((char*));614extern char *gdtoa ANSI((FPI *fpi, int be, ULong *bits, int *kindp,615int mode, int ndigits, int *decpt, char **rve));616extern char *g__fmt ANSI((char*, char*, char*, int, ULong, size_t));617extern int gethex ANSI((CONST char**, FPI*, Long*, Bigint**, int));618extern void hexdig_init_D2A(Void);619extern int hexnan ANSI((CONST char**, FPI*, ULong*));620extern int hi0bits ANSI((ULong));621extern Bigint *i2b ANSI((int));622extern Bigint *increment ANSI((Bigint*));623extern int lo0bits ANSI((ULong*));624extern Bigint *lshift ANSI((Bigint*, int));625extern int match ANSI((CONST char**, char*));626extern Bigint *mult ANSI((Bigint*, Bigint*));627extern Bigint *multadd ANSI((Bigint*, int, int));628extern char *nrv_alloc ANSI((char*, char **, int));629extern Bigint *pow5mult ANSI((Bigint*, int));630extern int quorem ANSI((Bigint*, Bigint*));631extern double ratio ANSI((Bigint*, Bigint*));632extern void rshift ANSI((Bigint*, int));633extern char *rv_alloc ANSI((int));634extern Bigint *s2b ANSI((CONST char*, int, int, ULong, int));635extern Bigint *set_ones ANSI((Bigint*, int));636extern char *strcp ANSI((char*, const char*));637extern int strtodg_l ANSI((CONST char*, char**, FPI*, Long*, ULong*, locale_t));638639extern int strtoId ANSI((CONST char *, char **, double *, double *));640extern int strtoIdd ANSI((CONST char *, char **, double *, double *));641extern int strtoIf ANSI((CONST char *, char **, float *, float *));642extern int strtoIg ANSI((CONST char*, char**, FPI*, Long*, Bigint**, int*));643extern int strtoIQ ANSI((CONST char *, char **, void *, void *));644extern int strtoIx ANSI((CONST char *, char **, void *, void *));645extern int strtoIxL ANSI((CONST char *, char **, void *, void *));646extern double strtod ANSI((const char *s00, char **se));647extern double strtod_l ANSI((const char *s00, char **se, locale_t));648extern int strtopQ ANSI((CONST char *, char **, Void *));649extern int strtopf ANSI((CONST char *, char **, float *));650extern int strtopd ANSI((CONST char *, char **, double *));651extern int strtopdd ANSI((CONST char *, char **, double *));652extern int strtopx ANSI((CONST char *, char **, Void *));653extern int strtopxL ANSI((CONST char *, char **, Void *));654extern int strtord_l ANSI((CONST char *, char **, int, double *, locale_t));655extern int strtordd ANSI((CONST char *, char **, int, double *));656extern int strtorf ANSI((CONST char *, char **, int, float *));657extern int strtorQ_l ANSI((CONST char *, char **, int, void *, locale_t));658extern int strtorx_l ANSI((CONST char *, char **, int, void *, locale_t));659extern int strtorxL ANSI((CONST char *, char **, int, void *));660extern Bigint *sum ANSI((Bigint*, Bigint*));661extern int trailz ANSI((Bigint*));662extern double ulp ANSI((U*));663664#ifdef __cplusplus665}666#endif667/*668* NAN_WORD0 and NAN_WORD1 are only referenced in strtod.c. Prior to669* 20050115, they used to be hard-wired here (to 0x7ff80000 and 0,670* respectively), but now are determined by compiling and running671* qnan.c to generate gd_qnan.h, which specifies d_QNAN0 and d_QNAN1.672* Formerly gdtoaimp.h recommended supplying suitable -DNAN_WORD0=...673* and -DNAN_WORD1=... values if necessary. This should still work.674* (On HP Series 700/800 machines, -DNAN_WORD0=0x7ff40000 works.)675*/676#ifdef IEEE_Arith677#ifndef NO_INFNAN_CHECK678#undef INFNAN_CHECK679#define INFNAN_CHECK680#endif681#ifdef IEEE_MC68k682#define _0 0683#define _1 1684#ifndef NAN_WORD0685#define NAN_WORD0 d_QNAN0686#endif687#ifndef NAN_WORD1688#define NAN_WORD1 d_QNAN1689#endif690#else691#define _0 1692#define _1 0693#ifndef NAN_WORD0694#define NAN_WORD0 d_QNAN1695#endif696#ifndef NAN_WORD1697#define NAN_WORD1 d_QNAN0698#endif699#endif700#else701#undef INFNAN_CHECK702#endif703704#undef SI705#ifdef Sudden_Underflow706#define SI 1707#else708#define SI 0709#endif710711#endif /* GDTOAIMP_H_INCLUDED */712713714