1 --- _hdtoa.c.orig 2004-06-03 15:22:08.000000000 -0700
2 +++ _hdtoa.c 2004-08-28 17:10:21.000000000 -0700
7 +#ifdef LDBL_HEAD_TAIL_PAIR
9 +#endif /* LDBL_HEAD_TAIL_PAIR */
15 int shift; /* for subnormals, # of shifts required to normalize */
16 int sigfigs; /* number of significant hex figures in result */
17 +#ifdef LDBL_HEAD_TAIL_PAIR
20 +#endif /* LDBL_HEAD_TAIL_PAIR */
25 +#ifdef LDBL_HEAD_TAIL_PAIR
26 + switch (__fpclassifyd(u.d[0])) {
27 +#else /* LDBL_HEAD_TAIL_PAIR */
28 switch (fpclassify(e)) {
29 +#endif /* LDBL_HEAD_TAIL_PAIR */
31 +#ifdef LDBL_HEAD_TAIL_PAIR
32 sigfigs = (LDBL_MANT_DIG + 3) / 4;
33 impnbit = 1 << ((LDBL_MANT_DIG - 1) % 4);
34 *decpt = u.bits.exp - LDBL_BIAS + 1 -
35 ((LDBL_MANT_DIG - 1) % 4);
36 +#else /* LDBL_HEAD_TAIL_PAIR */
37 + sigfigs = (LDBL_MANT_DIG + 3) / 4;
38 + impnbit = 1 << ((LDBL_MANT_DIG - 1) % 4);
39 + *decpt = u.bits.exp - LDBL_BIAS + 1 -
40 + ((LDBL_MANT_DIG - 1) % 4);
41 +#endif /* LDBL_HEAD_TAIL_PAIR */
46 /* Don't trust the normalization bit to be off. */
47 u.bits.manh &= ~(~0ULL << (LDBL_MANH_SIZE - 1));
49 +#ifndef LDBL_HEAD_TAIL_PAIR
50 if (u.bits.manh != 0) {
51 +#endif /* LDBL_HEAD_TAIL_PAIR */
52 #if LDBL_MANH_SIZE > 32
53 pos = log2_64(u.bits.manh);
55 pos = log2_32(u.bits.manh);
57 shift = LDBL_MANH_SIZE - LDBL_NBIT_ADJ - pos;
58 +#ifdef LDBL_HEAD_TAIL_PAIR
59 + sigfigs = (3 + LDBL_MANT_DIG - LDBL_NBIT_ADJ - shift) / 4;
60 + // we use DBL_MIN_EXP below because the head double is
61 + // subnormal (and the tail double is zero)
62 + *decpt = DBL_MIN_EXP + LDBL_NBIT_ADJ;
63 + pos = (LDBL_MANT_DIG + 3) % 4;
65 + *decpt -= pos + ((shift - pos + 3) & ~(4 - 1));
68 +#else /* LDBL_HEAD_TAIL_PAIR */
70 #if LDBL_MANL_SIZE > 32
71 pos = log2_64(u.bits.manl);
75 sigfigs = (3 + LDBL_MANT_DIG - LDBL_NBIT_ADJ - shift) / 4;
76 - *decpt = LDBL_MIN_EXP + LDBL_NBIT_ADJ -
77 + *decpt = DBL_MIN_EXP + LDBL_NBIT_ADJ -
78 ((shift + 3) & ~(4 - 1));
79 +#endif /* LDBL_HEAD_TAIL_PAIR */
85 for (s = s0 + bufsize - 1; s > s0 + sigfigs - 1; s--)
87 +#ifdef LDBL_HEAD_TAIL_PAIR
88 + _ldbl2array32dd(u, bits);
91 + for (; s > s0; s--) {
99 +#else /* LDBL_HEAD_TAIL_PAIR */
100 for (; s > s0 + sigfigs - (LDBL_MANL_SIZE / 4) - 1 && s > s0; s--) {
101 *s = u.bits.manl & 0xf;
104 *s = u.bits.manh & 0xf;
107 +#endif /* LDBL_HEAD_TAIL_PAIR */
110 * At this point, we have snarfed all the bits in the
112 * in manl instead for small subnormals. We also tack on the
113 * implicit normalization bit if appropriate.
115 +#ifdef LDBL_HEAD_TAIL_PAIR
116 + *s = bits[i] | impnbit;
117 +#else /* LDBL_HEAD_TAIL_PAIR */
118 *s = u.bits.manh | u.bits.manl | impnbit;
119 +#endif /* LDBL_HEAD_TAIL_PAIR */
121 /* If ndigits < 0, we are expected to auto-size the precision. */