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