- *decpt = 1;
-@@ -328,13 +346,26 @@
- /* Don't trust the normalization bit to be off. */
- u.bits.manh &= ~(~0ULL << (LDBL_MANH_SIZE - 1));
- #endif
-+#ifndef LDBL_HEAD_TAIL_PAIR
- if (u.bits.manh != 0) {
-+#endif /* LDBL_HEAD_TAIL_PAIR */
- #if LDBL_MANH_SIZE > 32
- pos = log2_64(u.bits.manh);
- #else
- pos = log2_32(u.bits.manh);
- #endif
- shift = LDBL_MANH_SIZE - LDBL_NBIT_ADJ - pos;
-+#ifdef LDBL_HEAD_TAIL_PAIR
-+ sigfigs = (3 + LDBL_MANT_DIG - LDBL_NBIT_ADJ - shift) / 4;
-+ // we use DBL_MIN_EXP below because the head double is
-+ // subnormal (and the tail double is zero)
-+ *decpt = DBL_MIN_EXP + LDBL_NBIT_ADJ;
-+ pos = (LDBL_MANT_DIG + 3) % 4;
-+ if (pos < shift)
-+ *decpt -= pos + ((shift - pos + 3) & ~(4 - 1));
-+ else
-+ *decpt -= shift;
-+#else /* LDBL_HEAD_TAIL_PAIR */
- } else {
- #if LDBL_MANL_SIZE > 32
- pos = log2_64(u.bits.manl);
-@@ -345,8 +376,9 @@
- LDBL_NBIT_ADJ - pos;
- }
- sigfigs = (3 + LDBL_MANT_DIG - LDBL_NBIT_ADJ - shift) / 4;
-- *decpt = LDBL_MIN_EXP + LDBL_NBIT_ADJ -
-+ *decpt = DBL_MIN_EXP + LDBL_NBIT_ADJ -
- ((shift + 3) & ~(4 - 1));
-+#endif /* LDBL_HEAD_TAIL_PAIR */
- impnbit = 0;
- break;
- case FP_INFINITE:
-@@ -381,6 +413,19 @@
+@@ -245,7 +251,7 @@ __hldtoa(long double e, const char *xdig
+ *decpt = INT_MAX;
+ return (nrv_alloc(NANSTR, rve, sizeof(NANSTR) - 1));
+ default:
+- abort();
++ LIBC_ABORT("fpclassify returned %d", f);
+ }
+
+ /* FP_NORMAL or FP_SUBNORMAL */
+@@ -270,6 +276,19 @@ __hldtoa(long double e, const char *xdig