1cc36ccd1SDavid Schultz /**************************************************************** 2cc36ccd1SDavid Schultz 3cc36ccd1SDavid Schultz The author of this software is David M. Gay. 4cc36ccd1SDavid Schultz 5cc36ccd1SDavid Schultz Copyright (C) 1998-2000 by Lucent Technologies 6cc36ccd1SDavid Schultz All Rights Reserved 7cc36ccd1SDavid Schultz 8cc36ccd1SDavid Schultz Permission to use, copy, modify, and distribute this software and 9cc36ccd1SDavid Schultz its documentation for any purpose and without fee is hereby 10cc36ccd1SDavid Schultz granted, provided that the above copyright notice appear in all 11cc36ccd1SDavid Schultz copies and that both that the copyright notice and this 12cc36ccd1SDavid Schultz permission notice and warranty disclaimer appear in supporting 13cc36ccd1SDavid Schultz documentation, and that the name of Lucent or any of its entities 14cc36ccd1SDavid Schultz not be used in advertising or publicity pertaining to 15cc36ccd1SDavid Schultz distribution of the software without specific, written prior 16cc36ccd1SDavid Schultz permission. 17cc36ccd1SDavid Schultz 18cc36ccd1SDavid Schultz LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 19cc36ccd1SDavid Schultz INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. 20cc36ccd1SDavid Schultz IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY 21cc36ccd1SDavid Schultz SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 22cc36ccd1SDavid Schultz WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 23cc36ccd1SDavid Schultz IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 24cc36ccd1SDavid Schultz ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 25cc36ccd1SDavid Schultz THIS SOFTWARE. 26cc36ccd1SDavid Schultz 27cc36ccd1SDavid Schultz ****************************************************************/ 28cc36ccd1SDavid Schultz 29de9840c6SDavid Schultz /* $FreeBSD$ */ 30de9840c6SDavid Schultz 31cc36ccd1SDavid Schultz /* This is a variation on dtoa.c that converts arbitary binary 32cc36ccd1SDavid Schultz floating-point formats to and from decimal notation. It uses 33cc36ccd1SDavid Schultz double-precision arithmetic internally, so there are still 34cc36ccd1SDavid Schultz various #ifdefs that adapt the calculations to the native 35cc36ccd1SDavid Schultz double-precision arithmetic (any of IEEE, VAX D_floating, 36cc36ccd1SDavid Schultz or IBM mainframe arithmetic). 37cc36ccd1SDavid Schultz 38cc36ccd1SDavid Schultz Please send bug reports to 39cc36ccd1SDavid Schultz David M. Gay 40cc36ccd1SDavid Schultz Bell Laboratories, Room 2C-463 41cc36ccd1SDavid Schultz 600 Mountain Avenue 42cc36ccd1SDavid Schultz Murray Hill, NJ 07974-0636 43cc36ccd1SDavid Schultz U.S.A. 44cc36ccd1SDavid Schultz dmg@bell-labs.com 45cc36ccd1SDavid Schultz */ 46cc36ccd1SDavid Schultz 47cc36ccd1SDavid Schultz /* On a machine with IEEE extended-precision registers, it is 48cc36ccd1SDavid Schultz * necessary to specify double-precision (53-bit) rounding precision 49cc36ccd1SDavid Schultz * before invoking strtod or dtoa. If the machine uses (the equivalent 50cc36ccd1SDavid Schultz * of) Intel 80x87 arithmetic, the call 51cc36ccd1SDavid Schultz * _control87(PC_53, MCW_PC); 52cc36ccd1SDavid Schultz * does this with many compilers. Whether this or another call is 53cc36ccd1SDavid Schultz * appropriate depends on the compiler; for this to work, it may be 54cc36ccd1SDavid Schultz * necessary to #include "float.h" or another system-dependent header 55cc36ccd1SDavid Schultz * file. 56cc36ccd1SDavid Schultz */ 57cc36ccd1SDavid Schultz 58cc36ccd1SDavid Schultz /* strtod for IEEE-, VAX-, and IBM-arithmetic machines. 59cc36ccd1SDavid Schultz * 60cc36ccd1SDavid Schultz * This strtod returns a nearest machine number to the input decimal 61cc36ccd1SDavid Schultz * string (or sets errno to ERANGE). With IEEE arithmetic, ties are 62cc36ccd1SDavid Schultz * broken by the IEEE round-even rule. Otherwise ties are broken by 63cc36ccd1SDavid Schultz * biased rounding (add half and chop). 64cc36ccd1SDavid Schultz * 65cc36ccd1SDavid Schultz * Inspired loosely by William D. Clinger's paper "How to Read Floating 66cc36ccd1SDavid Schultz * Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101]. 67cc36ccd1SDavid Schultz * 68cc36ccd1SDavid Schultz * Modifications: 69cc36ccd1SDavid Schultz * 70cc36ccd1SDavid Schultz * 1. We only require IEEE, IBM, or VAX double-precision 71cc36ccd1SDavid Schultz * arithmetic (not IEEE double-extended). 72cc36ccd1SDavid Schultz * 2. We get by with floating-point arithmetic in a case that 73cc36ccd1SDavid Schultz * Clinger missed -- when we're computing d * 10^n 74cc36ccd1SDavid Schultz * for a small integer d and the integer n is not too 75cc36ccd1SDavid Schultz * much larger than 22 (the maximum integer k for which 76cc36ccd1SDavid Schultz * we can represent 10^k exactly), we may be able to 77cc36ccd1SDavid Schultz * compute (d*10^k) * 10^(e-k) with just one roundoff. 78cc36ccd1SDavid Schultz * 3. Rather than a bit-at-a-time adjustment of the binary 79cc36ccd1SDavid Schultz * result in the hard case, we use floating-point 80cc36ccd1SDavid Schultz * arithmetic to determine the adjustment to within 81cc36ccd1SDavid Schultz * one bit; only in really hard cases do we need to 82cc36ccd1SDavid Schultz * compute a second residual. 83cc36ccd1SDavid Schultz * 4. Because of 3., we don't need a large table of powers of 10 84cc36ccd1SDavid Schultz * for ten-to-e (just some small tables, e.g. of 10^k 85cc36ccd1SDavid Schultz * for 0 <= k <= 22). 86cc36ccd1SDavid Schultz */ 87cc36ccd1SDavid Schultz 88cc36ccd1SDavid Schultz /* 89cc36ccd1SDavid Schultz * #define IEEE_8087 for IEEE-arithmetic machines where the least 90cc36ccd1SDavid Schultz * significant byte has the lowest address. 91cc36ccd1SDavid Schultz * #define IEEE_MC68k for IEEE-arithmetic machines where the most 92cc36ccd1SDavid Schultz * significant byte has the lowest address. 93cc36ccd1SDavid Schultz * #define Long int on machines with 32-bit ints and 64-bit longs. 94cc36ccd1SDavid Schultz * #define Sudden_Underflow for IEEE-format machines without gradual 95cc36ccd1SDavid Schultz * underflow (i.e., that flush to zero on underflow). 96cc36ccd1SDavid Schultz * #define IBM for IBM mainframe-style floating-point arithmetic. 97cc36ccd1SDavid Schultz * #define VAX for VAX-style floating-point arithmetic (D_floating). 98cc36ccd1SDavid Schultz * #define No_leftright to omit left-right logic in fast floating-point 99cc36ccd1SDavid Schultz * computation of dtoa. 100cc36ccd1SDavid Schultz * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3. 101cc36ccd1SDavid Schultz * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines 102cc36ccd1SDavid Schultz * that use extended-precision instructions to compute rounded 103cc36ccd1SDavid Schultz * products and quotients) with IBM. 104cc36ccd1SDavid Schultz * #define ROUND_BIASED for IEEE-format with biased rounding. 105cc36ccd1SDavid Schultz * #define Inaccurate_Divide for IEEE-format with correctly rounded 106cc36ccd1SDavid Schultz * products but inaccurate quotients, e.g., for Intel i860. 107cc36ccd1SDavid Schultz * #define NO_LONG_LONG on machines that do not have a "long long" 108cc36ccd1SDavid Schultz * integer type (of >= 64 bits). On such machines, you can 109cc36ccd1SDavid Schultz * #define Just_16 to store 16 bits per 32-bit Long when doing 110cc36ccd1SDavid Schultz * high-precision integer arithmetic. Whether this speeds things 111cc36ccd1SDavid Schultz * up or slows things down depends on the machine and the number 112cc36ccd1SDavid Schultz * being converted. If long long is available and the name is 113cc36ccd1SDavid Schultz * something other than "long long", #define Llong to be the name, 114cc36ccd1SDavid Schultz * and if "unsigned Llong" does not work as an unsigned version of 115cc36ccd1SDavid Schultz * Llong, #define #ULLong to be the corresponding unsigned type. 116cc36ccd1SDavid Schultz * #define KR_headers for old-style C function headers. 117cc36ccd1SDavid Schultz * #define Bad_float_h if your system lacks a float.h or if it does not 118cc36ccd1SDavid Schultz * define some or all of DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP, 119cc36ccd1SDavid Schultz * FLT_RADIX, FLT_ROUNDS, and DBL_MAX. 120cc36ccd1SDavid Schultz * #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n) 121cc36ccd1SDavid Schultz * if memory is available and otherwise does something you deem 122cc36ccd1SDavid Schultz * appropriate. If MALLOC is undefined, malloc will be invoked 123cc36ccd1SDavid Schultz * directly -- and assumed always to succeed. 124cc36ccd1SDavid Schultz * #define Omit_Private_Memory to omit logic (added Jan. 1998) for making 125cc36ccd1SDavid Schultz * memory allocations from a private pool of memory when possible. 126cc36ccd1SDavid Schultz * When used, the private pool is PRIVATE_MEM bytes long: 2304 bytes, 127cc36ccd1SDavid Schultz * unless #defined to be a different length. This default length 128cc36ccd1SDavid Schultz * suffices to get rid of MALLOC calls except for unusual cases, 129cc36ccd1SDavid Schultz * such as decimal-to-binary conversion of a very long string of 130cc36ccd1SDavid Schultz * digits. When converting IEEE double precision values, the 131cc36ccd1SDavid Schultz * longest string gdtoa can return is about 751 bytes long. For 132cc36ccd1SDavid Schultz * conversions by strtod of strings of 800 digits and all gdtoa 133cc36ccd1SDavid Schultz * conversions of IEEE doubles in single-threaded executions with 134cc36ccd1SDavid Schultz * 8-byte pointers, PRIVATE_MEM >= 7400 appears to suffice; with 135cc36ccd1SDavid Schultz * 4-byte pointers, PRIVATE_MEM >= 7112 appears adequate. 136cc36ccd1SDavid Schultz * #define INFNAN_CHECK on IEEE systems to cause strtod to check for 137cc36ccd1SDavid Schultz * Infinity and NaN (case insensitively). On some systems (e.g., 138cc36ccd1SDavid Schultz * some HP systems), it may be necessary to #define NAN_WORD0 139cc36ccd1SDavid Schultz * appropriately -- to the most significant word of a quiet NaN. 140cc36ccd1SDavid Schultz * (On HP Series 700/800 machines, -DNAN_WORD0=0x7ff40000 works.) 141cc36ccd1SDavid Schultz * When INFNAN_CHECK is #defined and No_Hex_NaN is not #defined, 142cc36ccd1SDavid Schultz * strtodg also accepts (case insensitively) strings of the form 143cc36ccd1SDavid Schultz * NaN(x), where x is a string of hexadecimal digits and spaces; 144cc36ccd1SDavid Schultz * if there is only one string of hexadecimal digits, it is taken 145cc36ccd1SDavid Schultz * for the fraction bits of the resulting NaN; if there are two or 146cc36ccd1SDavid Schultz * more strings of hexadecimal digits, each string is assigned 147cc36ccd1SDavid Schultz * to the next available sequence of 32-bit words of fractions 148cc36ccd1SDavid Schultz * bits (starting with the most significant), right-aligned in 149cc36ccd1SDavid Schultz * each sequence. 150cc36ccd1SDavid Schultz * #define MULTIPLE_THREADS if the system offers preemptively scheduled 151cc36ccd1SDavid Schultz * multiple threads. In this case, you must provide (or suitably 152cc36ccd1SDavid Schultz * #define) two locks, acquired by ACQUIRE_DTOA_LOCK(n) and freed 153cc36ccd1SDavid Schultz * by FREE_DTOA_LOCK(n) for n = 0 or 1. (The second lock, accessed 154cc36ccd1SDavid Schultz * in pow5mult, ensures lazy evaluation of only one copy of high 155cc36ccd1SDavid Schultz * powers of 5; omitting this lock would introduce a small 156cc36ccd1SDavid Schultz * probability of wasting memory, but would otherwise be harmless.) 157cc36ccd1SDavid Schultz * You must also invoke freedtoa(s) to free the value s returned by 158cc36ccd1SDavid Schultz * dtoa. You may do so whether or not MULTIPLE_THREADS is #defined. 159cc36ccd1SDavid Schultz * #define IMPRECISE_INEXACT if you do not care about the setting of 160cc36ccd1SDavid Schultz * the STRTOG_Inexact bits in the special case of doing IEEE double 161cc36ccd1SDavid Schultz * precision conversions (which could also be done by the strtog in 162cc36ccd1SDavid Schultz * dtoa.c). 163cc36ccd1SDavid Schultz * #define NO_HEX_FP to disable recognition of C9x's hexadecimal 164cc36ccd1SDavid Schultz * floating-point constants. 165cc36ccd1SDavid Schultz * #define -DNO_ERRNO to suppress setting errno (in strtod.c and 166cc36ccd1SDavid Schultz * strtodg.c). 167cc36ccd1SDavid Schultz * #define NO_STRING_H to use private versions of memcpy. 168cc36ccd1SDavid Schultz * On some K&R systems, it may also be necessary to 169cc36ccd1SDavid Schultz * #define DECLARE_SIZE_T in this case. 170cc36ccd1SDavid Schultz * #define YES_ALIAS to permit aliasing certain double values with 171cc36ccd1SDavid Schultz * arrays of ULongs. This leads to slightly better code with 172cc36ccd1SDavid Schultz * some compilers and was always used prior to 19990916, but it 173cc36ccd1SDavid Schultz * is not strictly legal and can cause trouble with aggressively 174cc36ccd1SDavid Schultz * optimizing compilers (e.g., gcc 2.95.1 under -O2). 175cc36ccd1SDavid Schultz * #define USE_LOCALE to use the current locale's decimal_point value. 176cc36ccd1SDavid Schultz */ 177cc36ccd1SDavid Schultz 178cc36ccd1SDavid Schultz #ifndef GDTOAIMP_H_INCLUDED 179cc36ccd1SDavid Schultz #define GDTOAIMP_H_INCLUDED 180cc36ccd1SDavid Schultz #include "gdtoa.h" 181cc36ccd1SDavid Schultz 182cc36ccd1SDavid Schultz #ifdef DEBUG 183cc36ccd1SDavid Schultz #include "stdio.h" 184cc36ccd1SDavid Schultz #define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);} 185cc36ccd1SDavid Schultz #endif 186cc36ccd1SDavid Schultz 187de9840c6SDavid Schultz #include "limits.h" 188cc36ccd1SDavid Schultz #include "stdlib.h" 189cc36ccd1SDavid Schultz #include "string.h" 190de9840c6SDavid Schultz #include "libc_private.h" 191d086ded3SDavid Schultz 192d086ded3SDavid Schultz #include "namespace.h" 193d086ded3SDavid Schultz #include <pthread.h> 194d086ded3SDavid Schultz #include "un-namespace.h" 195cc36ccd1SDavid Schultz 196cc36ccd1SDavid Schultz #ifdef KR_headers 197cc36ccd1SDavid Schultz #define Char char 198cc36ccd1SDavid Schultz #else 199cc36ccd1SDavid Schultz #define Char void 200cc36ccd1SDavid Schultz #endif 201cc36ccd1SDavid Schultz 202cc36ccd1SDavid Schultz #ifdef MALLOC 203cc36ccd1SDavid Schultz extern Char *MALLOC ANSI((size_t)); 204cc36ccd1SDavid Schultz #else 205cc36ccd1SDavid Schultz #define MALLOC malloc 206cc36ccd1SDavid Schultz #endif 207cc36ccd1SDavid Schultz 208de9840c6SDavid Schultz #define INFNAN_CHECK 2091dd3a3dbSDavid Schultz #define USE_LOCALE 210de9840c6SDavid Schultz 211cc36ccd1SDavid Schultz #undef IEEE_Arith 212cc36ccd1SDavid Schultz #undef Avoid_Underflow 213cc36ccd1SDavid Schultz #ifdef IEEE_MC68k 214cc36ccd1SDavid Schultz #define IEEE_Arith 215cc36ccd1SDavid Schultz #endif 216cc36ccd1SDavid Schultz #ifdef IEEE_8087 217cc36ccd1SDavid Schultz #define IEEE_Arith 218cc36ccd1SDavid Schultz #endif 219cc36ccd1SDavid Schultz 220cc36ccd1SDavid Schultz #include "errno.h" 221cc36ccd1SDavid Schultz #ifdef Bad_float_h 222cc36ccd1SDavid Schultz 223cc36ccd1SDavid Schultz #ifdef IEEE_Arith 224cc36ccd1SDavid Schultz #define DBL_DIG 15 225cc36ccd1SDavid Schultz #define DBL_MAX_10_EXP 308 226cc36ccd1SDavid Schultz #define DBL_MAX_EXP 1024 227cc36ccd1SDavid Schultz #define FLT_RADIX 2 228cc36ccd1SDavid Schultz #define DBL_MAX 1.7976931348623157e+308 229cc36ccd1SDavid Schultz #endif 230cc36ccd1SDavid Schultz 231cc36ccd1SDavid Schultz #ifdef IBM 232cc36ccd1SDavid Schultz #define DBL_DIG 16 233cc36ccd1SDavid Schultz #define DBL_MAX_10_EXP 75 234cc36ccd1SDavid Schultz #define DBL_MAX_EXP 63 235cc36ccd1SDavid Schultz #define FLT_RADIX 16 236cc36ccd1SDavid Schultz #define DBL_MAX 7.2370055773322621e+75 237cc36ccd1SDavid Schultz #endif 238cc36ccd1SDavid Schultz 239cc36ccd1SDavid Schultz #ifdef VAX 240cc36ccd1SDavid Schultz #define DBL_DIG 16 241cc36ccd1SDavid Schultz #define DBL_MAX_10_EXP 38 242cc36ccd1SDavid Schultz #define DBL_MAX_EXP 127 243cc36ccd1SDavid Schultz #define FLT_RADIX 2 244cc36ccd1SDavid Schultz #define DBL_MAX 1.7014118346046923e+38 245cc36ccd1SDavid Schultz #define n_bigtens 2 246cc36ccd1SDavid Schultz #endif 247cc36ccd1SDavid Schultz 248cc36ccd1SDavid Schultz #ifndef LONG_MAX 249cc36ccd1SDavid Schultz #define LONG_MAX 2147483647 250cc36ccd1SDavid Schultz #endif 251cc36ccd1SDavid Schultz 252cc36ccd1SDavid Schultz #else /* ifndef Bad_float_h */ 253cc36ccd1SDavid Schultz #include "float.h" 254cc36ccd1SDavid Schultz #endif /* Bad_float_h */ 255cc36ccd1SDavid Schultz 256cc36ccd1SDavid Schultz #ifdef IEEE_Arith 257cc36ccd1SDavid Schultz #define Scale_Bit 0x10 258cc36ccd1SDavid Schultz #define n_bigtens 5 259cc36ccd1SDavid Schultz #endif 260cc36ccd1SDavid Schultz 261cc36ccd1SDavid Schultz #ifdef IBM 262cc36ccd1SDavid Schultz #define n_bigtens 3 263cc36ccd1SDavid Schultz #endif 264cc36ccd1SDavid Schultz 265cc36ccd1SDavid Schultz #ifdef VAX 266cc36ccd1SDavid Schultz #define n_bigtens 2 267cc36ccd1SDavid Schultz #endif 268cc36ccd1SDavid Schultz 269cc36ccd1SDavid Schultz #ifndef __MATH_H__ 270cc36ccd1SDavid Schultz #include "math.h" 271cc36ccd1SDavid Schultz #endif 272cc36ccd1SDavid Schultz 273cc36ccd1SDavid Schultz #ifdef __cplusplus 274cc36ccd1SDavid Schultz extern "C" { 275cc36ccd1SDavid Schultz #endif 276cc36ccd1SDavid Schultz 277cc36ccd1SDavid Schultz #if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1 278cc36ccd1SDavid Schultz Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined. 279cc36ccd1SDavid Schultz #endif 280cc36ccd1SDavid Schultz 281cc36ccd1SDavid Schultz typedef union { double d; ULong L[2]; } U; 282cc36ccd1SDavid Schultz 283cc36ccd1SDavid Schultz #ifdef YES_ALIAS 284cc36ccd1SDavid Schultz #define dval(x) x 285cc36ccd1SDavid Schultz #ifdef IEEE_8087 286cc36ccd1SDavid Schultz #define word0(x) ((ULong *)&x)[1] 287cc36ccd1SDavid Schultz #define word1(x) ((ULong *)&x)[0] 288cc36ccd1SDavid Schultz #else 289cc36ccd1SDavid Schultz #define word0(x) ((ULong *)&x)[0] 290cc36ccd1SDavid Schultz #define word1(x) ((ULong *)&x)[1] 291cc36ccd1SDavid Schultz #endif 292cc36ccd1SDavid Schultz #else /* !YES_ALIAS */ 293cc36ccd1SDavid Schultz #ifdef IEEE_8087 294cc36ccd1SDavid Schultz #define word0(x) ((U*)&x)->L[1] 295cc36ccd1SDavid Schultz #define word1(x) ((U*)&x)->L[0] 296cc36ccd1SDavid Schultz #else 297cc36ccd1SDavid Schultz #define word0(x) ((U*)&x)->L[0] 298cc36ccd1SDavid Schultz #define word1(x) ((U*)&x)->L[1] 299cc36ccd1SDavid Schultz #endif 300cc36ccd1SDavid Schultz #define dval(x) ((U*)&x)->d 301cc36ccd1SDavid Schultz #endif /* YES_ALIAS */ 302cc36ccd1SDavid Schultz 303cc36ccd1SDavid Schultz /* The following definition of Storeinc is appropriate for MIPS processors. 304cc36ccd1SDavid Schultz * An alternative that might be better on some machines is 305cc36ccd1SDavid Schultz * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff) 306cc36ccd1SDavid Schultz */ 307cc36ccd1SDavid Schultz #if defined(IEEE_8087) + defined(VAX) 308cc36ccd1SDavid Schultz #define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \ 309cc36ccd1SDavid Schultz ((unsigned short *)a)[0] = (unsigned short)c, a++) 310cc36ccd1SDavid Schultz #else 311cc36ccd1SDavid Schultz #define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \ 312cc36ccd1SDavid Schultz ((unsigned short *)a)[1] = (unsigned short)c, a++) 313cc36ccd1SDavid Schultz #endif 314cc36ccd1SDavid Schultz 315cc36ccd1SDavid Schultz /* #define P DBL_MANT_DIG */ 316cc36ccd1SDavid Schultz /* Ten_pmax = floor(P*log(2)/log(5)) */ 317cc36ccd1SDavid Schultz /* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */ 318cc36ccd1SDavid Schultz /* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */ 319cc36ccd1SDavid Schultz /* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */ 320cc36ccd1SDavid Schultz 321cc36ccd1SDavid Schultz #ifdef IEEE_Arith 322cc36ccd1SDavid Schultz #define Exp_shift 20 323cc36ccd1SDavid Schultz #define Exp_shift1 20 324cc36ccd1SDavid Schultz #define Exp_msk1 0x100000 325cc36ccd1SDavid Schultz #define Exp_msk11 0x100000 326cc36ccd1SDavid Schultz #define Exp_mask 0x7ff00000 327cc36ccd1SDavid Schultz #define P 53 328cc36ccd1SDavid Schultz #define Bias 1023 329cc36ccd1SDavid Schultz #define Emin (-1022) 330cc36ccd1SDavid Schultz #define Exp_1 0x3ff00000 331cc36ccd1SDavid Schultz #define Exp_11 0x3ff00000 332cc36ccd1SDavid Schultz #define Ebits 11 333cc36ccd1SDavid Schultz #define Frac_mask 0xfffff 334cc36ccd1SDavid Schultz #define Frac_mask1 0xfffff 335cc36ccd1SDavid Schultz #define Ten_pmax 22 336cc36ccd1SDavid Schultz #define Bletch 0x10 337cc36ccd1SDavid Schultz #define Bndry_mask 0xfffff 338cc36ccd1SDavid Schultz #define Bndry_mask1 0xfffff 339cc36ccd1SDavid Schultz #define LSB 1 340cc36ccd1SDavid Schultz #define Sign_bit 0x80000000 341cc36ccd1SDavid Schultz #define Log2P 1 342cc36ccd1SDavid Schultz #define Tiny0 0 343cc36ccd1SDavid Schultz #define Tiny1 1 344cc36ccd1SDavid Schultz #define Quick_max 14 345cc36ccd1SDavid Schultz #define Int_max 14 346cc36ccd1SDavid Schultz 347cc36ccd1SDavid Schultz #ifndef Flt_Rounds 348cc36ccd1SDavid Schultz #ifdef FLT_ROUNDS 349cc36ccd1SDavid Schultz #define Flt_Rounds FLT_ROUNDS 350cc36ccd1SDavid Schultz #else 351cc36ccd1SDavid Schultz #define Flt_Rounds 1 352cc36ccd1SDavid Schultz #endif 353cc36ccd1SDavid Schultz #endif /*Flt_Rounds*/ 354cc36ccd1SDavid Schultz 355cc36ccd1SDavid Schultz #else /* ifndef IEEE_Arith */ 356cc36ccd1SDavid Schultz #undef Sudden_Underflow 357cc36ccd1SDavid Schultz #define Sudden_Underflow 358cc36ccd1SDavid Schultz #ifdef IBM 359cc36ccd1SDavid Schultz #undef Flt_Rounds 360cc36ccd1SDavid Schultz #define Flt_Rounds 0 361cc36ccd1SDavid Schultz #define Exp_shift 24 362cc36ccd1SDavid Schultz #define Exp_shift1 24 363cc36ccd1SDavid Schultz #define Exp_msk1 0x1000000 364cc36ccd1SDavid Schultz #define Exp_msk11 0x1000000 365cc36ccd1SDavid Schultz #define Exp_mask 0x7f000000 366cc36ccd1SDavid Schultz #define P 14 367cc36ccd1SDavid Schultz #define Bias 65 368cc36ccd1SDavid Schultz #define Exp_1 0x41000000 369cc36ccd1SDavid Schultz #define Exp_11 0x41000000 370cc36ccd1SDavid Schultz #define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */ 371cc36ccd1SDavid Schultz #define Frac_mask 0xffffff 372cc36ccd1SDavid Schultz #define Frac_mask1 0xffffff 373cc36ccd1SDavid Schultz #define Bletch 4 374cc36ccd1SDavid Schultz #define Ten_pmax 22 375cc36ccd1SDavid Schultz #define Bndry_mask 0xefffff 376cc36ccd1SDavid Schultz #define Bndry_mask1 0xffffff 377cc36ccd1SDavid Schultz #define LSB 1 378cc36ccd1SDavid Schultz #define Sign_bit 0x80000000 379cc36ccd1SDavid Schultz #define Log2P 4 380cc36ccd1SDavid Schultz #define Tiny0 0x100000 381cc36ccd1SDavid Schultz #define Tiny1 0 382cc36ccd1SDavid Schultz #define Quick_max 14 383cc36ccd1SDavid Schultz #define Int_max 15 384cc36ccd1SDavid Schultz #else /* VAX */ 385cc36ccd1SDavid Schultz #undef Flt_Rounds 386cc36ccd1SDavid Schultz #define Flt_Rounds 1 387cc36ccd1SDavid Schultz #define Exp_shift 23 388cc36ccd1SDavid Schultz #define Exp_shift1 7 389cc36ccd1SDavid Schultz #define Exp_msk1 0x80 390cc36ccd1SDavid Schultz #define Exp_msk11 0x800000 391cc36ccd1SDavid Schultz #define Exp_mask 0x7f80 392cc36ccd1SDavid Schultz #define P 56 393cc36ccd1SDavid Schultz #define Bias 129 394cc36ccd1SDavid Schultz #define Exp_1 0x40800000 395cc36ccd1SDavid Schultz #define Exp_11 0x4080 396cc36ccd1SDavid Schultz #define Ebits 8 397cc36ccd1SDavid Schultz #define Frac_mask 0x7fffff 398cc36ccd1SDavid Schultz #define Frac_mask1 0xffff007f 399cc36ccd1SDavid Schultz #define Ten_pmax 24 400cc36ccd1SDavid Schultz #define Bletch 2 401cc36ccd1SDavid Schultz #define Bndry_mask 0xffff007f 402cc36ccd1SDavid Schultz #define Bndry_mask1 0xffff007f 403cc36ccd1SDavid Schultz #define LSB 0x10000 404cc36ccd1SDavid Schultz #define Sign_bit 0x8000 405cc36ccd1SDavid Schultz #define Log2P 1 406cc36ccd1SDavid Schultz #define Tiny0 0x80 407cc36ccd1SDavid Schultz #define Tiny1 0 408cc36ccd1SDavid Schultz #define Quick_max 15 409cc36ccd1SDavid Schultz #define Int_max 15 410cc36ccd1SDavid Schultz #endif /* IBM, VAX */ 411cc36ccd1SDavid Schultz #endif /* IEEE_Arith */ 412cc36ccd1SDavid Schultz 413cc36ccd1SDavid Schultz #ifndef IEEE_Arith 414cc36ccd1SDavid Schultz #define ROUND_BIASED 415cc36ccd1SDavid Schultz #endif 416cc36ccd1SDavid Schultz 417cc36ccd1SDavid Schultz #ifdef RND_PRODQUOT 418cc36ccd1SDavid Schultz #define rounded_product(a,b) a = rnd_prod(a, b) 419cc36ccd1SDavid Schultz #define rounded_quotient(a,b) a = rnd_quot(a, b) 420cc36ccd1SDavid Schultz #ifdef KR_headers 421cc36ccd1SDavid Schultz extern double rnd_prod(), rnd_quot(); 422cc36ccd1SDavid Schultz #else 423cc36ccd1SDavid Schultz extern double rnd_prod(double, double), rnd_quot(double, double); 424cc36ccd1SDavid Schultz #endif 425cc36ccd1SDavid Schultz #else 426cc36ccd1SDavid Schultz #define rounded_product(a,b) a *= b 427cc36ccd1SDavid Schultz #define rounded_quotient(a,b) a /= b 428cc36ccd1SDavid Schultz #endif 429cc36ccd1SDavid Schultz 430cc36ccd1SDavid Schultz #define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1)) 431cc36ccd1SDavid Schultz #define Big1 0xffffffff 432cc36ccd1SDavid Schultz 433cc36ccd1SDavid Schultz #undef Pack_16 434cc36ccd1SDavid Schultz #ifndef Pack_32 435cc36ccd1SDavid Schultz #define Pack_32 436cc36ccd1SDavid Schultz #endif 437cc36ccd1SDavid Schultz 438cc36ccd1SDavid Schultz #ifdef NO_LONG_LONG 439cc36ccd1SDavid Schultz #undef ULLong 440cc36ccd1SDavid Schultz #ifdef Just_16 441cc36ccd1SDavid Schultz #undef Pack_32 442cc36ccd1SDavid Schultz #define Pack_16 443cc36ccd1SDavid Schultz /* When Pack_32 is not defined, we store 16 bits per 32-bit Long. 444cc36ccd1SDavid Schultz * This makes some inner loops simpler and sometimes saves work 445cc36ccd1SDavid Schultz * during multiplications, but it often seems to make things slightly 446cc36ccd1SDavid Schultz * slower. Hence the default is now to store 32 bits per Long. 447cc36ccd1SDavid Schultz */ 448cc36ccd1SDavid Schultz #endif 449cc36ccd1SDavid Schultz #else /* long long available */ 450cc36ccd1SDavid Schultz #ifndef Llong 451cc36ccd1SDavid Schultz #define Llong long long 452cc36ccd1SDavid Schultz #endif 453cc36ccd1SDavid Schultz #ifndef ULLong 454cc36ccd1SDavid Schultz #define ULLong unsigned Llong 455cc36ccd1SDavid Schultz #endif 456cc36ccd1SDavid Schultz #endif /* NO_LONG_LONG */ 457cc36ccd1SDavid Schultz 458cc36ccd1SDavid Schultz #ifdef Pack_32 459cc36ccd1SDavid Schultz #define ULbits 32 460cc36ccd1SDavid Schultz #define kshift 5 461cc36ccd1SDavid Schultz #define kmask 31 462cc36ccd1SDavid Schultz #define ALL_ON 0xffffffff 463cc36ccd1SDavid Schultz #else 464cc36ccd1SDavid Schultz #define ULbits 16 465cc36ccd1SDavid Schultz #define kshift 4 466cc36ccd1SDavid Schultz #define kmask 15 467cc36ccd1SDavid Schultz #define ALL_ON 0xffff 468cc36ccd1SDavid Schultz #endif 469cc36ccd1SDavid Schultz 470de9840c6SDavid Schultz #define MULTIPLE_THREADS 471d086ded3SDavid Schultz extern pthread_mutex_t __gdtoa_locks[2]; 472de9840c6SDavid Schultz #define ACQUIRE_DTOA_LOCK(n) do { \ 473de9840c6SDavid Schultz if (__isthreaded) \ 474d086ded3SDavid Schultz _pthread_mutex_lock(&__gdtoa_locks[n]); \ 475de9840c6SDavid Schultz } while(0) 476de9840c6SDavid Schultz #define FREE_DTOA_LOCK(n) do { \ 477de9840c6SDavid Schultz if (__isthreaded) \ 478d086ded3SDavid Schultz _pthread_mutex_unlock(&__gdtoa_locks[n]); \ 479de9840c6SDavid Schultz } while(0) 480cc36ccd1SDavid Schultz 481cc36ccd1SDavid Schultz #define Kmax 15 482cc36ccd1SDavid Schultz 483cc36ccd1SDavid Schultz struct 484cc36ccd1SDavid Schultz Bigint { 485cc36ccd1SDavid Schultz struct Bigint *next; 486cc36ccd1SDavid Schultz int k, maxwds, sign, wds; 487cc36ccd1SDavid Schultz ULong x[1]; 488cc36ccd1SDavid Schultz }; 489cc36ccd1SDavid Schultz 490cc36ccd1SDavid Schultz typedef struct Bigint Bigint; 491cc36ccd1SDavid Schultz 492cc36ccd1SDavid Schultz #ifdef NO_STRING_H 493cc36ccd1SDavid Schultz #ifdef DECLARE_SIZE_T 494cc36ccd1SDavid Schultz typedef unsigned int size_t; 495cc36ccd1SDavid Schultz #endif 496cc36ccd1SDavid Schultz extern void memcpy_D2A ANSI((void*, const void*, size_t)); 497cc36ccd1SDavid Schultz #define Bcopy(x,y) memcpy_D2A(&x->sign,&y->sign,y->wds*sizeof(ULong) + 2*sizeof(int)) 498cc36ccd1SDavid Schultz #else /* !NO_STRING_H */ 499cc36ccd1SDavid Schultz #define Bcopy(x,y) memcpy(&x->sign,&y->sign,y->wds*sizeof(ULong) + 2*sizeof(int)) 500cc36ccd1SDavid Schultz #endif /* NO_STRING_H */ 501cc36ccd1SDavid Schultz 502de9840c6SDavid Schultz /* 503de9840c6SDavid Schultz * Paranoia: Protect exported symbols, including ones in files we don't 504de9840c6SDavid Schultz * compile right now. The standard strtof and strtod survive. 505de9840c6SDavid Schultz */ 506de9840c6SDavid Schultz #define dtoa __dtoa 507de9840c6SDavid Schultz #define gdtoa __gdtoa 508de9840c6SDavid Schultz #define freedtoa __freedtoa 509de9840c6SDavid Schultz #define strtodg __strtodg 510de9840c6SDavid Schultz #define g_ddfmt __g_ddfmt 511de9840c6SDavid Schultz #define g_dfmt __g_dfmt 512de9840c6SDavid Schultz #define g_ffmt __g_ffmt 513de9840c6SDavid Schultz #define g_Qfmt __g_Qfmt 514de9840c6SDavid Schultz #define g_xfmt __g_xfmt 515de9840c6SDavid Schultz #define g_xLfmt __g_xLfmt 516de9840c6SDavid Schultz #define strtoId __strtoId 517de9840c6SDavid Schultz #define strtoIdd __strtoIdd 518de9840c6SDavid Schultz #define strtoIf __strtoIf 519de9840c6SDavid Schultz #define strtoIQ __strtoIQ 520de9840c6SDavid Schultz #define strtoIx __strtoIx 521de9840c6SDavid Schultz #define strtoIxL __strtoIxL 522de9840c6SDavid Schultz #define strtord __strtord 523de9840c6SDavid Schultz #define strtordd __strtordd 524de9840c6SDavid Schultz #define strtorf __strtorf 525de9840c6SDavid Schultz #define strtorQ __strtorQ 526de9840c6SDavid Schultz #define strtorx __strtorx 527de9840c6SDavid Schultz #define strtorxL __strtorxL 528de9840c6SDavid Schultz #define strtodI __strtodI 529de9840c6SDavid Schultz #define strtopd __strtopd 530de9840c6SDavid Schultz #define strtopdd __strtopdd 531de9840c6SDavid Schultz #define strtopf __strtopf 532de9840c6SDavid Schultz #define strtopQ __strtopQ 533de9840c6SDavid Schultz #define strtopx __strtopx 534de9840c6SDavid Schultz #define strtopxL __strtopxL 535de9840c6SDavid Schultz 536de9840c6SDavid Schultz /* Protect gdtoa-internal symbols */ 537de9840c6SDavid Schultz #define Balloc __Balloc_D2A 538de9840c6SDavid Schultz #define Bfree __Bfree_D2A 539de9840c6SDavid Schultz #define ULtoQ __ULtoQ_D2A 540de9840c6SDavid Schultz #define ULtof __ULtof_D2A 541de9840c6SDavid Schultz #define ULtod __ULtod_D2A 542de9840c6SDavid Schultz #define ULtodd __ULtodd_D2A 543de9840c6SDavid Schultz #define ULtox __ULtox_D2A 544de9840c6SDavid Schultz #define ULtoxL __ULtoxL_D2A 545de9840c6SDavid Schultz #define any_on __any_on_D2A 546de9840c6SDavid Schultz #define b2d __b2d_D2A 547de9840c6SDavid Schultz #define bigtens __bigtens_D2A 548de9840c6SDavid Schultz #define cmp __cmp_D2A 549de9840c6SDavid Schultz #define copybits __copybits_D2A 550de9840c6SDavid Schultz #define d2b __d2b_D2A 551de9840c6SDavid Schultz #define decrement __decrement_D2A 552de9840c6SDavid Schultz #define diff __diff_D2A 553de9840c6SDavid Schultz #define dtoa_result __dtoa_result_D2A 554de9840c6SDavid Schultz #define g__fmt __g__fmt_D2A 555de9840c6SDavid Schultz #define gethex __gethex_D2A 556de9840c6SDavid Schultz #define hexdig __hexdig_D2A 557de9840c6SDavid Schultz #define hexdig_init_D2A __hexdig_init_D2A 558de9840c6SDavid Schultz #define hexnan __hexnan_D2A 559de9840c6SDavid Schultz #define hi0bits __hi0bits_D2A 560de9840c6SDavid Schultz #define i2b __i2b_D2A 561de9840c6SDavid Schultz #define increment __increment_D2A 562de9840c6SDavid Schultz #define lo0bits __lo0bits_D2A 563de9840c6SDavid Schultz #define lshift __lshift_D2A 564de9840c6SDavid Schultz #define match __match_D2A 565de9840c6SDavid Schultz #define mult __mult_D2A 566de9840c6SDavid Schultz #define multadd __multadd_D2A 567de9840c6SDavid Schultz #define nrv_alloc __nrv_alloc_D2A 568de9840c6SDavid Schultz #define pow5mult __pow5mult_D2A 569de9840c6SDavid Schultz #define quorem __quorem_D2A 570de9840c6SDavid Schultz #define ratio __ratio_D2A 571de9840c6SDavid Schultz #define rshift __rshift_D2A 572de9840c6SDavid Schultz #define rv_alloc __rv_alloc_D2A 573de9840c6SDavid Schultz #define s2b __s2b_D2A 574de9840c6SDavid Schultz #define set_ones __set_ones_D2A 575de9840c6SDavid Schultz #define strcp __strcp_D2A 576de9840c6SDavid Schultz #define strcp_D2A __strcp_D2A 577de9840c6SDavid Schultz #define strtoIg __strtoIg_D2A 578de9840c6SDavid Schultz #define sum __sum_D2A 579de9840c6SDavid Schultz #define tens __tens_D2A 580de9840c6SDavid Schultz #define tinytens __tinytens_D2A 581de9840c6SDavid Schultz #define tinytens __tinytens_D2A 582de9840c6SDavid Schultz #define trailz __trailz_D2A 583de9840c6SDavid Schultz #define ulp __ulp_D2A 584cc36ccd1SDavid Schultz 585cc36ccd1SDavid Schultz extern char *dtoa_result; 586cc36ccd1SDavid Schultz extern CONST double bigtens[], tens[], tinytens[]; 587cc36ccd1SDavid Schultz extern unsigned char hexdig[]; 588cc36ccd1SDavid Schultz 589cc36ccd1SDavid Schultz extern Bigint *Balloc ANSI((int)); 590cc36ccd1SDavid Schultz extern void Bfree ANSI((Bigint*)); 591cc36ccd1SDavid Schultz extern void ULtof ANSI((ULong*, ULong*, Long, int)); 592cc36ccd1SDavid Schultz extern void ULtod ANSI((ULong*, ULong*, Long, int)); 593cc36ccd1SDavid Schultz extern void ULtodd ANSI((ULong*, ULong*, Long, int)); 594cc36ccd1SDavid Schultz extern void ULtoQ ANSI((ULong*, ULong*, Long, int)); 595cc36ccd1SDavid Schultz extern void ULtox ANSI((UShort*, ULong*, Long, int)); 596cc36ccd1SDavid Schultz extern void ULtoxL ANSI((ULong*, ULong*, Long, int)); 597cc36ccd1SDavid Schultz extern ULong any_on ANSI((Bigint*, int)); 598cc36ccd1SDavid Schultz extern double b2d ANSI((Bigint*, int*)); 599cc36ccd1SDavid Schultz extern int cmp ANSI((Bigint*, Bigint*)); 600cc36ccd1SDavid Schultz extern void copybits ANSI((ULong*, int, Bigint*)); 601cc36ccd1SDavid Schultz extern Bigint *d2b ANSI((double, int*, int*)); 602cc36ccd1SDavid Schultz extern int decrement ANSI((Bigint*)); 603cc36ccd1SDavid Schultz extern Bigint *diff ANSI((Bigint*, Bigint*)); 604cc36ccd1SDavid Schultz extern char *dtoa ANSI((double d, int mode, int ndigits, 605cc36ccd1SDavid Schultz int *decpt, int *sign, char **rve)); 60668369762SDavid Schultz extern void freedtoa ANSI((char*)); 607628f583cSDavid Schultz extern char *gdtoa ANSI((FPI *fpi, int be, ULong *bits, int *kindp, 608628f583cSDavid Schultz int mode, int ndigits, int *decpt, char **rve)); 609cc36ccd1SDavid Schultz extern char *g__fmt ANSI((char*, char*, char*, int, ULong)); 610cc36ccd1SDavid Schultz extern int gethex ANSI((CONST char**, FPI*, Long*, Bigint**, int)); 611cc36ccd1SDavid Schultz extern void hexdig_init_D2A(Void); 612cc36ccd1SDavid Schultz extern int hexnan ANSI((CONST char**, FPI*, ULong*)); 613cc36ccd1SDavid Schultz extern int hi0bits ANSI((ULong)); 614cc36ccd1SDavid Schultz extern Bigint *i2b ANSI((int)); 615cc36ccd1SDavid Schultz extern Bigint *increment ANSI((Bigint*)); 616cc36ccd1SDavid Schultz extern int lo0bits ANSI((ULong*)); 617cc36ccd1SDavid Schultz extern Bigint *lshift ANSI((Bigint*, int)); 618cc36ccd1SDavid Schultz extern int match ANSI((CONST char**, char*)); 619cc36ccd1SDavid Schultz extern Bigint *mult ANSI((Bigint*, Bigint*)); 620cc36ccd1SDavid Schultz extern Bigint *multadd ANSI((Bigint*, int, int)); 621cc36ccd1SDavid Schultz extern char *nrv_alloc ANSI((char*, char **, int)); 622cc36ccd1SDavid Schultz extern Bigint *pow5mult ANSI((Bigint*, int)); 623cc36ccd1SDavid Schultz extern int quorem ANSI((Bigint*, Bigint*)); 624cc36ccd1SDavid Schultz extern double ratio ANSI((Bigint*, Bigint*)); 625cc36ccd1SDavid Schultz extern void rshift ANSI((Bigint*, int)); 626cc36ccd1SDavid Schultz extern char *rv_alloc ANSI((int)); 627cc36ccd1SDavid Schultz extern Bigint *s2b ANSI((CONST char*, int, int, ULong)); 628cc36ccd1SDavid Schultz extern Bigint *set_ones ANSI((Bigint*, int)); 629cc36ccd1SDavid Schultz extern char *strcp ANSI((char*, const char*)); 63068369762SDavid Schultz extern int strtodg ANSI((CONST char*, char**, FPI*, Long*, ULong*)); 63168369762SDavid Schultz 63268369762SDavid Schultz extern int strtoId ANSI((CONST char *, char **, double *, double *)); 63368369762SDavid Schultz extern int strtoIdd ANSI((CONST char *, char **, double *, double *)); 63468369762SDavid Schultz extern int strtoIf ANSI((CONST char *, char **, float *, float *)); 635cc36ccd1SDavid Schultz extern int strtoIg ANSI((CONST char*, char**, FPI*, Long*, Bigint**, int*)); 63668369762SDavid Schultz extern int strtoIQ ANSI((CONST char *, char **, void *, void *)); 63768369762SDavid Schultz extern int strtoIx ANSI((CONST char *, char **, void *, void *)); 63868369762SDavid Schultz extern int strtoIxL ANSI((CONST char *, char **, void *, void *)); 639cc36ccd1SDavid Schultz extern double strtod ANSI((const char *s00, char **se)); 64068369762SDavid Schultz extern int strtopQ ANSI((CONST char *, char **, Void *)); 64168369762SDavid Schultz extern int strtopf ANSI((CONST char *, char **, float *)); 64268369762SDavid Schultz extern int strtopd ANSI((CONST char *, char **, double *)); 64368369762SDavid Schultz extern int strtopdd ANSI((CONST char *, char **, double *)); 64468369762SDavid Schultz extern int strtopx ANSI((CONST char *, char **, Void *)); 64568369762SDavid Schultz extern int strtopxL ANSI((CONST char *, char **, Void *)); 64668369762SDavid Schultz extern int strtord ANSI((CONST char *, char **, int, double *)); 64768369762SDavid Schultz extern int strtordd ANSI((CONST char *, char **, int, double *)); 64868369762SDavid Schultz extern int strtorf ANSI((CONST char *, char **, int, float *)); 64968369762SDavid Schultz extern int strtorQ ANSI((CONST char *, char **, int, void *)); 65068369762SDavid Schultz extern int strtorx ANSI((CONST char *, char **, int, void *)); 65168369762SDavid Schultz extern int strtorxL ANSI((CONST char *, char **, int, void *)); 652cc36ccd1SDavid Schultz extern Bigint *sum ANSI((Bigint*, Bigint*)); 653cc36ccd1SDavid Schultz extern int trailz ANSI((Bigint*)); 654cc36ccd1SDavid Schultz extern double ulp ANSI((double)); 655cc36ccd1SDavid Schultz 656cc36ccd1SDavid Schultz #ifdef __cplusplus 657cc36ccd1SDavid Schultz } 658cc36ccd1SDavid Schultz #endif 659cc36ccd1SDavid Schultz 660cc36ccd1SDavid Schultz 661cc36ccd1SDavid Schultz #ifdef IEEE_Arith 662cc36ccd1SDavid Schultz #ifdef IEEE_MC68k 663cc36ccd1SDavid Schultz #define _0 0 664cc36ccd1SDavid Schultz #define _1 1 665cc36ccd1SDavid Schultz #else 666cc36ccd1SDavid Schultz #define _0 1 667cc36ccd1SDavid Schultz #define _1 0 668cc36ccd1SDavid Schultz #endif 669cc36ccd1SDavid Schultz #else 670cc36ccd1SDavid Schultz #undef INFNAN_CHECK 671cc36ccd1SDavid Schultz #endif 672cc36ccd1SDavid Schultz 673cc36ccd1SDavid Schultz #ifdef INFNAN_CHECK 674cc36ccd1SDavid Schultz 675cc36ccd1SDavid Schultz #ifndef NAN_WORD0 676cc36ccd1SDavid Schultz #define NAN_WORD0 0x7ff80000 677cc36ccd1SDavid Schultz #endif 678cc36ccd1SDavid Schultz 679cc36ccd1SDavid Schultz #ifndef NAN_WORD1 680cc36ccd1SDavid Schultz #define NAN_WORD1 0 681cc36ccd1SDavid Schultz #endif 682cc36ccd1SDavid Schultz #endif /* INFNAN_CHECK */ 683cc36ccd1SDavid Schultz 684cc36ccd1SDavid Schultz #undef SI 685cc36ccd1SDavid Schultz #ifdef Sudden_Underflow 686cc36ccd1SDavid Schultz #define SI 1 687cc36ccd1SDavid Schultz #else 688cc36ccd1SDavid Schultz #define SI 0 689cc36ccd1SDavid Schultz #endif 690cc36ccd1SDavid Schultz 691cc36ccd1SDavid Schultz #endif /* GDTOAIMP_H_INCLUDED */ 692