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