aboutsummaryrefslogtreecommitdiff
path: root/lib/msun
diff options
context:
space:
mode:
authorBruce Evans <bde@FreeBSD.org>2018-07-19 14:24:48 +0000
committerBruce Evans <bde@FreeBSD.org>2018-07-19 14:24:48 +0000
commit50c8bd4e537903cb8ebfdda99fa0f030ec3698cd (patch)
tree344a442474c9a01d4a1cd471d93aed2ae10f109c /lib/msun
parent17e98da88efac7587744785e20234b712ecb6edb (diff)
Notes
Diffstat (limited to 'lib/msun')
-rw-r--r--lib/msun/src/s_csqrtl.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/msun/src/s_csqrtl.c b/lib/msun/src/s_csqrtl.c
index 5ab9406558af..fad53b9e9295 100644
--- a/lib/msun/src/s_csqrtl.c
+++ b/lib/msun/src/s_csqrtl.c
@@ -36,17 +36,22 @@ __FBSDID("$FreeBSD$");
#include "math_private.h"
/*
- * THRESH is now calculated portably (up to 113-bit precision). However,
- * the denormal threshold is hard-coded for a 15-bit exponent with the usual
- * bias. s_logl.c and e_hypotl have less hard-coding but end up requiring
- * the same for the exponent and more for the mantissa.
+ * Several thresholds require a 15-bit exponent and also the usual bias.
+ * s_logl.c and e_hypotl have less hard-coding but end up requiring the
+ * same for the exponent and more for the mantissa.
*/
#if LDBL_MAX_EXP != 0x4000
#error "Unsupported long double format"
#endif
-/* For avoiding overflow for components >= LDBL_MAX / (1 + sqrt(2)). */
-#define THRESH (LDBL_MAX / 2.414213562373095048801688724209698L)
+/*
+ * Overflow must be avoided for components >= LDBL_MAX / (1 + sqrt(2)).
+ * The precise threshold is nontrivial to determine and spell, so use a
+ * lower threshold of approximaely LDBL_MAX / 4, and don't use LDBL_MAX
+ * to spell this since LDBL_MAX is broken on i386 (it overflows in 53-bit
+ * precision).
+ */
+#define THRESH 0x1p16382L
long double complex
csqrtl(long double complex z)