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