From f964490f3c4f094fd684960c2e98885b23e31376 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 28 Jan 2006 00:15:15 +0000 Subject: 2006-01-27 Dwayne Grant McConnell Jakub Jelinek Roland McGrath Steven Munroe Alan Modra * sysdeps/powerpc/powerpc64/fpu/s_truncf.S: Comment fix. * sysdeps/powerpc/powerpc32/fpu/s_truncf.S: Likewise. * sysdeps/powerpc/powerpc64/fpu/s_llroundf.S: Likewise. * sysdeps/powerpc/fpu/libm-test-ulps: Update. * math/libm-test.inc (check_float_internal): Allow ulp <= 0.5. (erfc_test): Don't run erfcl (27.0L) test if erfcl (27.0L) is denormal. [TEST_LDOUBLE] (ceil_test, floor_test, llrint_test, llround_test, rint_test, round_test, trunc_test): Add new tests. * sysdeps/powerpc/powerpc32/fpu/s_copysignl.S: New file. * sysdeps/powerpc/powerpc32/fpu/s_fabs.S: New file. * sysdeps/powerpc/powerpc32/fpu/s_fabsl.S: New file. * sysdeps/powerpc/powerpc32/fpu/s_fdim.c: New file. * sysdeps/powerpc/powerpc32/fpu/s_fmax.S: New file. * sysdeps/powerpc/powerpc32/fpu/s_fmin.S: New file. * sysdeps/powerpc/powerpc32/fpu/s_isnan.c: New file. * sysdeps/powerpc/powerpc64/fpu/s_ceill.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_copysignl.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_fabs.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_fabsl.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_fdim.c: New file. * sysdeps/powerpc/powerpc64/fpu/s_floorl.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_fmax.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_fmin.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_isnan.c: New file. * sysdeps/powerpc/powerpc64/fpu/s_llrintl.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_llroundl.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_lrintl.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_lroundl.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_nearbyintl.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_rintl.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_roundl.S: New file. * sysdeps/powerpc/powerpc64/fpu/s_truncl.S: New file. * sysdeps/unix/sysv/linux/powerpc/Implies: New file. * sysdeps/unix/sysv/linux/powerpc/powerpc64/fpu/Implies: New file. * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/Implies: New file. * sysdeps/unix/sysv/linux/powerpc/configure.in: New file. * sysdeps/unix/sysv/linux/powerpc/configure: New file. * sysdeps/unix/sysv/linux/powerpc/bits/wordsize.h (__LONG_DOUBLE_MATH_OPTIONAL): Define. (__NO_LONG_DOUBLE_MATH): Define. * sysdeps/unix/sysv/linux/powerpc/nldbl-abi.h: New file. * sysdeps/powerpc/fpu/s_isnan.c: Include math_ldbl_opt.h. * sysdeps/powerpc/powerpc64/fpu/s_ceil.S: Include math_ldbl_opt.h. [LONG_DOUBLE_COMPAT] (ceill): Add compatibility symbols. * sysdeps/powerpc/powerpc64/fpu/s_copysign.S: Include math_ldbl_opt.h. [LONG_DOUBLE_COMPAT] (copysignl): Add compatibility symbols. * sysdeps/powerpc/powerpc64/fpu/s_floor.S: Include math_ldbl_opt.h. [LONG_DOUBLE_COMPAT] (floorl): Add compatibility symbols. * sysdeps/powerpc/powerpc64/fpu/s_llrint.S: Include math_ldbl_opt.h. [LONG_DOUBLE_COMPAT] (llrintl, lrintl): Add compatibility symbols. * sysdeps/powerpc/powerpc64/fpu/s_llround.S: Include math_ldbl_opt.h. [LONG_DOUBLE_COMPAT] (llroundl, lroundl): Add compatibility symbols. * sysdeps/powerpc/powerpc64/fpu/s_rint.S: Include math_ldbl_opt.h. [LONG_DOUBLE_COMPAT] (rintl): Add compatibility symbols. * sysdeps/powerpc/powerpc64/fpu/s_round.S: Include math_ldbl_opt.h. [LONG_DOUBLE_COMPAT] (roundl): Add compatibility symbols. * sysdeps/powerpc/powerpc64/fpu/s_trunc.S: Include math_ldbl_opt.h. [LONG_DOUBLE_COMPAT] (truncl): Add compatibility symbols. * sysdeps/powerpc/powerpc32/fpu/s_ceil.S: Include math_ldbl_opt.h. [LONG_DOUBLE_COMPAT] (ceill): Add compatibility symbols. * sysdeps/powerpc/powerpc32/fpu/s_copysign.S: Include math_ldbl_opt.h. [LONG_DOUBLE_COMPAT] (copysignl): Add compatibility symbols. * sysdeps/powerpc/powerpc32/fpu/s_floor.S: Include math_ldbl_opt.h. [LONG_DOUBLE_COMPAT] (floorl): Add compatibility symbols. * sysdeps/powerpc/powerpc32/fpu/s_lrint.S: Include math_ldbl_opt.h. [LONG_DOUBLE_COMPAT] (lrintl): Add compatibility symbols. * sysdeps/powerpc/powerpc32/fpu/s_llrint.c: Include math_ldbl_opt.h. [LONG_DOUBLE_COMPAT] (llrintl): Add compatibility symbols. * sysdeps/powerpc/powerpc32/fpu/s_lround.S: Include math_ldbl_opt.h. [LONG_DOUBLE_COMPAT] (lroundl): Add compatibility symbols. * sysdeps/powerpc/powerpc32/fpu/s_rint.S: Include math_ldbl_opt.h. [LONG_DOUBLE_COMPAT] (rintl): Add compatibility symbols. * sysdeps/powerpc/powerpc32/fpu/s_round.S: Include math_ldbl_opt.h. [LONG_DOUBLE_COMPAT] (roundl): Add compatibility symbols. * sysdeps/powerpc/powerpc32/fpu/s_trunc.S: Include math_ldbl_opt.h. [LONG_DOUBLE_COMPAT] (truncl): Add compatibility symbols. * misc/qefgcvt_r.c [LDBL_MIN_10_EXP == -291] (FLOAT_MIN_10_NORM): New. * sysdeps/powerpc/fpu/bits/mathdef.h (__NO_LONG_DOUBLE_MATH): Remove. * sysdeps/powerpc/Implies: Add ieee754/ldbl-128ibm. * sysdeps/powerpc/powerpc32/Implies: Remove powerpc/soft-fp. * sysdeps/ieee754/ldbl-128ibm/Makefile: New file. * sysdeps/ieee754/ldbl-128ibm/e_acoshl.c: New file. * sysdeps/ieee754/ldbl-128ibm/e_acosl.c: New file. * sysdeps/ieee754/ldbl-128ibm/e_asinl.c: New file. * sysdeps/ieee754/ldbl-128ibm/e_atan2l.c: New file. * sysdeps/ieee754/ldbl-128ibm/e_atanhl.c: New file. * sysdeps/ieee754/ldbl-128ibm/e_coshl.c: New file. * sysdeps/ieee754/ldbl-128ibm/e_expl.c: New file. * sysdeps/ieee754/ldbl-128ibm/e_fmodl.c: New file. * sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c: New file. * sysdeps/ieee754/ldbl-128ibm/e_hypotl.c: New file. * sysdeps/ieee754/ldbl-128ibm/e_j0l.c: New file. * sysdeps/ieee754/ldbl-128ibm/e_j1l.c: New file. * sysdeps/ieee754/ldbl-128ibm/e_jnl.c: New file. * sysdeps/ieee754/ldbl-128ibm/e_lgammal_r.c: New file. * sysdeps/ieee754/ldbl-128ibm/e_log10l.c: New file. * sysdeps/ieee754/ldbl-128ibm/e_log2l.c: New file. * sysdeps/ieee754/ldbl-128ibm/e_logl.c: New file. * sysdeps/ieee754/ldbl-128ibm/e_powl.c: New file. * sysdeps/ieee754/ldbl-128ibm/e_rem_pio2l.c: New file. * sysdeps/ieee754/ldbl-128ibm/e_remainderl.c: New file. * sysdeps/ieee754/ldbl-128ibm/e_sinhl.c: New file. * sysdeps/ieee754/ldbl-128ibm/e_sqrtl.c: New file. * sysdeps/ieee754/ldbl-128ibm/ieee754.h: New file. * sysdeps/ieee754/ldbl-128ibm/k_cosl.c: New file. * sysdeps/ieee754/ldbl-128ibm/k_sincosl.c: New file. * sysdeps/ieee754/ldbl-128ibm/k_sinl.c: New file. * sysdeps/ieee754/ldbl-128ibm/k_tanl.c: New file. * sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c: New file. * sysdeps/ieee754/ldbl-128ibm/math_ldbl.h: New file. * sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c: New file. * sysdeps/ieee754/ldbl-128ibm/printf_fphex.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_asinhl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_atanl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_cbrtl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_cosl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_erfl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_expm1l.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_fabsl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_finitel.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_fpclassifyl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_frexpl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_ilogbl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_isinfl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_isnanl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_log1pl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_logbl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_modfl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_remquol.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_rintl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_scalblnl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_scalbnl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_signbitl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_sincosl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_sinl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_tanhl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_tanl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_truncl.c: New file. * sysdeps/ieee754/ldbl-128ibm/strtold_l.c: New file. * sysdeps/ieee754/ldbl-128ibm/t_sincosl.c: New file. * sysdeps/ieee754/ldbl-128ibm/w_expl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_copysignl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_floorl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_llrintl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_llroundl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_roundl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_ceill.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_lrintl.c: New file. * sysdeps/ieee754/ldbl-128ibm/s_lroundl.c: New file. * sysdeps/ieee754/ldbl-128/e_powl.c: Fix old comment. --- ChangeLog | 170 ++++ math/libm-test.inc | 307 ++++++- misc/qefgcvt_r.c | 2 + sysdeps/ieee754/ldbl-128/e_powl.c | 2 +- sysdeps/ieee754/ldbl-128ibm/Makefile | 5 + sysdeps/ieee754/ldbl-128ibm/e_acoshl.c | 69 ++ sysdeps/ieee754/ldbl-128ibm/e_acosl.c | 328 +++++++ sysdeps/ieee754/ldbl-128ibm/e_asinl.c | 265 ++++++ sysdeps/ieee754/ldbl-128ibm/e_atan2l.c | 124 +++ sysdeps/ieee754/ldbl-128ibm/e_atanhl.c | 79 ++ sysdeps/ieee754/ldbl-128ibm/e_coshl.c | 90 ++ sysdeps/ieee754/ldbl-128ibm/e_expl.c | 257 ++++++ sysdeps/ieee754/ldbl-128ibm/e_fmodl.c | 145 ++++ sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c | 58 ++ sysdeps/ieee754/ldbl-128ibm/e_hypotl.c | 131 +++ sysdeps/ieee754/ldbl-128ibm/e_j0l.c | 3 + sysdeps/ieee754/ldbl-128ibm/e_j1l.c | 2 + sysdeps/ieee754/ldbl-128ibm/e_jnl.c | 402 +++++++++ sysdeps/ieee754/ldbl-128ibm/e_lgammal_r.c | 3 + sysdeps/ieee754/ldbl-128ibm/e_log10l.c | 258 ++++++ sysdeps/ieee754/ldbl-128ibm/e_log2l.c | 250 ++++++ sysdeps/ieee754/ldbl-128ibm/e_logl.c | 281 ++++++ sysdeps/ieee754/ldbl-128ibm/e_powl.c | 441 ++++++++++ sysdeps/ieee754/ldbl-128ibm/e_rem_pio2l.c | 277 ++++++ sysdeps/ieee754/ldbl-128ibm/e_remainderl.c | 78 ++ sysdeps/ieee754/ldbl-128ibm/e_sinhl.c | 84 ++ sysdeps/ieee754/ldbl-128ibm/e_sqrtl.c | 109 +++ sysdeps/ieee754/ldbl-128ibm/ieee754.h | 210 +++++ sysdeps/ieee754/ldbl-128ibm/k_cosl.c | 128 +++ sysdeps/ieee754/ldbl-128ibm/k_sincosl.c | 163 ++++ sysdeps/ieee754/ldbl-128ibm/k_sinl.c | 132 +++ sysdeps/ieee754/ldbl-128ibm/k_tanl.c | 164 ++++ sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c | 175 ++++ sysdeps/ieee754/ldbl-128ibm/math_ldbl.h | 124 +++ sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c | 103 +++ sysdeps/ieee754/ldbl-128ibm/printf_fphex.c | 138 +++ sysdeps/ieee754/ldbl-128ibm/s_asinhl.c | 67 ++ sysdeps/ieee754/ldbl-128ibm/s_atanl.c | 234 +++++ sysdeps/ieee754/ldbl-128ibm/s_cbrtl.c | 6 + sysdeps/ieee754/ldbl-128ibm/s_ceill.c | 119 +++ sysdeps/ieee754/ldbl-128ibm/s_copysignl.c | 45 + sysdeps/ieee754/ldbl-128ibm/s_cosl.c | 88 ++ sysdeps/ieee754/ldbl-128ibm/s_erfl.c | 958 +++++++++++++++++++++ sysdeps/ieee754/ldbl-128ibm/s_expm1l.c | 160 ++++ sysdeps/ieee754/ldbl-128ibm/s_fabsl.c | 43 + sysdeps/ieee754/ldbl-128ibm/s_finitel.c | 42 + sysdeps/ieee754/ldbl-128ibm/s_floorl.c | 118 +++ sysdeps/ieee754/ldbl-128ibm/s_fpclassifyl.c | 82 ++ sysdeps/ieee754/ldbl-128ibm/s_frexpl.c | 92 ++ sysdeps/ieee754/ldbl-128ibm/s_ilogbl.c | 63 ++ sysdeps/ieee754/ldbl-128ibm/s_isinfl.c | 35 + sysdeps/ieee754/ldbl-128ibm/s_isnanl.c | 43 + sysdeps/ieee754/ldbl-128ibm/s_llrintl.c | 124 +++ sysdeps/ieee754/ldbl-128ibm/s_llroundl.c | 128 +++ sysdeps/ieee754/ldbl-128ibm/s_log1pl.c | 257 ++++++ sysdeps/ieee754/ldbl-128ibm/s_logbl.c | 47 + sysdeps/ieee754/ldbl-128ibm/s_lrintl.c | 9 + sysdeps/ieee754/ldbl-128ibm/s_lroundl.c | 9 + sysdeps/ieee754/ldbl-128ibm/s_modfl.c | 94 ++ sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c | 125 +++ sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c | 108 +++ sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c | 106 +++ sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c | 83 ++ sysdeps/ieee754/ldbl-128ibm/s_remquol.c | 111 +++ sysdeps/ieee754/ldbl-128ibm/s_rintl.c | 119 +++ sysdeps/ieee754/ldbl-128ibm/s_roundl.c | 120 +++ sysdeps/ieee754/ldbl-128ibm/s_scalblnl.c | 105 +++ sysdeps/ieee754/ldbl-128ibm/s_scalbnl.c | 109 +++ sysdeps/ieee754/ldbl-128ibm/s_signbitl.c | 37 + sysdeps/ieee754/ldbl-128ibm/s_sincosl.c | 72 ++ sysdeps/ieee754/ldbl-128ibm/s_sinl.c | 84 ++ sysdeps/ieee754/ldbl-128ibm/s_tanhl.c | 90 ++ sysdeps/ieee754/ldbl-128ibm/s_tanl.c | 78 ++ sysdeps/ieee754/ldbl-128ibm/s_truncl.c | 119 +++ sysdeps/ieee754/ldbl-128ibm/strtold_l.c | 63 ++ sysdeps/ieee754/ldbl-128ibm/t_sincosl.c | 694 +++++++++++++++ sysdeps/ieee754/ldbl-128ibm/w_expl.c | 6 + sysdeps/powerpc/Implies | 4 +- sysdeps/powerpc/fpu/bits/mathdef.h | 9 +- sysdeps/powerpc/fpu/libm-test-ulps | 596 ++++++++++--- sysdeps/powerpc/fpu/s_isnan.c | 3 +- sysdeps/powerpc/powerpc32/Implies | 1 - sysdeps/powerpc/powerpc32/fpu/s_ceil.S | 4 + sysdeps/powerpc/powerpc32/fpu/s_copysign.S | 9 + sysdeps/powerpc/powerpc32/fpu/s_copysignl.S | 50 ++ sysdeps/powerpc/powerpc32/fpu/s_fabs.S | 5 + sysdeps/powerpc/powerpc32/fpu/s_fabsl.S | 36 + sysdeps/powerpc/powerpc32/fpu/s_fdim.c | 5 + sysdeps/powerpc/powerpc32/fpu/s_floor.S | 4 + sysdeps/powerpc/powerpc32/fpu/s_fmax.S | 5 + sysdeps/powerpc/powerpc32/fpu/s_fmin.S | 5 + sysdeps/powerpc/powerpc32/fpu/s_isnan.c | 7 + sysdeps/powerpc/powerpc32/fpu/s_llrint.c | 8 +- sysdeps/powerpc/powerpc32/fpu/s_lrint.S | 6 +- sysdeps/powerpc/powerpc32/fpu/s_lround.S | 4 + sysdeps/powerpc/powerpc32/fpu/s_rint.S | 4 + sysdeps/powerpc/powerpc32/fpu/s_round.S | 4 + sysdeps/powerpc/powerpc32/fpu/s_trunc.S | 6 +- sysdeps/powerpc/powerpc32/fpu/s_truncf.S | 2 +- sysdeps/powerpc/powerpc64/fpu/s_ceil.S | 6 +- sysdeps/powerpc/powerpc64/fpu/s_ceill.S | 133 +++ sysdeps/powerpc/powerpc64/fpu/s_copysign.S | 10 +- sysdeps/powerpc/powerpc64/fpu/s_copysignl.S | 51 ++ sysdeps/powerpc/powerpc64/fpu/s_fabs.S | 5 + sysdeps/powerpc/powerpc64/fpu/s_fabsl.S | 36 + sysdeps/powerpc/powerpc64/fpu/s_fdim.c | 5 + sysdeps/powerpc/powerpc64/fpu/s_floor.S | 6 +- sysdeps/powerpc/powerpc64/fpu/s_floorl.S | 134 +++ sysdeps/powerpc/powerpc64/fpu/s_fmax.S | 5 + sysdeps/powerpc/powerpc64/fpu/s_fmin.S | 5 + sysdeps/powerpc/powerpc64/fpu/s_isnan.c | 7 + sysdeps/powerpc/powerpc64/fpu/s_llrint.S | 7 +- sysdeps/powerpc/powerpc64/fpu/s_llrintl.S | 94 ++ sysdeps/powerpc/powerpc64/fpu/s_llround.S | 7 +- sysdeps/powerpc/powerpc64/fpu/s_llroundf.S | 6 +- sysdeps/powerpc/powerpc64/fpu/s_llroundl.S | 147 ++++ sysdeps/powerpc/powerpc64/fpu/s_lrintl.S | 2 + sysdeps/powerpc/powerpc64/fpu/s_lroundl.S | 2 + sysdeps/powerpc/powerpc64/fpu/s_nearbyintl.S | 114 +++ sysdeps/powerpc/powerpc64/fpu/s_rint.S | 6 +- sysdeps/powerpc/powerpc64/fpu/s_rintl.S | 113 +++ sysdeps/powerpc/powerpc64/fpu/s_round.S | 6 +- sysdeps/powerpc/powerpc64/fpu/s_roundl.S | 133 +++ sysdeps/powerpc/powerpc64/fpu/s_trunc.S | 8 +- sysdeps/powerpc/powerpc64/fpu/s_truncf.S | 4 +- sysdeps/powerpc/powerpc64/fpu/s_truncl.S | 121 +++ sysdeps/unix/sysv/linux/powerpc/Implies | 4 + sysdeps/unix/sysv/linux/powerpc/bits/wordsize.h | 19 + sysdeps/unix/sysv/linux/powerpc/configure | 135 +++ sysdeps/unix/sysv/linux/powerpc/configure.in | 37 + sysdeps/unix/sysv/linux/powerpc/nldbl-abi.h | 8 + .../unix/sysv/linux/powerpc/powerpc32/fpu/Implies | 2 + .../unix/sysv/linux/powerpc/powerpc64/fpu/Implies | 2 + 133 files changed, 12670 insertions(+), 136 deletions(-) create mode 100644 sysdeps/ieee754/ldbl-128ibm/Makefile create mode 100644 sysdeps/ieee754/ldbl-128ibm/e_acoshl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/e_acosl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/e_asinl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/e_atan2l.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/e_atanhl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/e_coshl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/e_expl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/e_fmodl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/e_hypotl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/e_j0l.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/e_j1l.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/e_jnl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/e_lgammal_r.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/e_log10l.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/e_log2l.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/e_logl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/e_powl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/e_rem_pio2l.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/e_remainderl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/e_sinhl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/e_sqrtl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/ieee754.h create mode 100644 sysdeps/ieee754/ldbl-128ibm/k_cosl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/k_sincosl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/k_sinl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/k_tanl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/math_ldbl.h create mode 100644 sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/printf_fphex.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_asinhl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_atanl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_cbrtl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_ceill.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_copysignl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_cosl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_erfl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_expm1l.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_fabsl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_finitel.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_floorl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_fpclassifyl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_frexpl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_ilogbl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_isinfl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_isnanl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_llrintl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_llroundl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_log1pl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_logbl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_lrintl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_lroundl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_modfl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_remquol.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_rintl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_roundl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_scalblnl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_scalbnl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_signbitl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_sincosl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_sinl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_tanhl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_tanl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/s_truncl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/strtold_l.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/t_sincosl.c create mode 100644 sysdeps/ieee754/ldbl-128ibm/w_expl.c create mode 100644 sysdeps/powerpc/powerpc32/fpu/s_copysignl.S create mode 100644 sysdeps/powerpc/powerpc32/fpu/s_fabs.S create mode 100644 sysdeps/powerpc/powerpc32/fpu/s_fabsl.S create mode 100644 sysdeps/powerpc/powerpc32/fpu/s_fdim.c create mode 100644 sysdeps/powerpc/powerpc32/fpu/s_fmax.S create mode 100644 sysdeps/powerpc/powerpc32/fpu/s_fmin.S create mode 100644 sysdeps/powerpc/powerpc32/fpu/s_isnan.c create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_ceill.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_copysignl.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_fabs.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_fabsl.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_fdim.c create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_floorl.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_fmax.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_fmin.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_isnan.c create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_llrintl.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_llroundl.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_lrintl.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_lroundl.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_nearbyintl.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_rintl.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_roundl.S create mode 100644 sysdeps/powerpc/powerpc64/fpu/s_truncl.S create mode 100644 sysdeps/unix/sysv/linux/powerpc/Implies create mode 100644 sysdeps/unix/sysv/linux/powerpc/bits/wordsize.h create mode 100644 sysdeps/unix/sysv/linux/powerpc/configure create mode 100644 sysdeps/unix/sysv/linux/powerpc/configure.in create mode 100644 sysdeps/unix/sysv/linux/powerpc/nldbl-abi.h create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/Implies create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/fpu/Implies diff --git a/ChangeLog b/ChangeLog index 874ce3f..bfcdc51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,173 @@ +2006-01-27 Dwayne Grant McConnell + Jakub Jelinek + Roland McGrath + Steven Munroe + Alan Modra + + * sysdeps/powerpc/powerpc64/fpu/s_truncf.S: Comment fix. + * sysdeps/powerpc/powerpc32/fpu/s_truncf.S: Likewise. + * sysdeps/powerpc/powerpc64/fpu/s_llroundf.S: Likewise. + + * sysdeps/powerpc/fpu/libm-test-ulps: Update. + + * math/libm-test.inc (check_float_internal): Allow ulp <= 0.5. + (erfc_test): Don't run erfcl (27.0L) test if erfcl (27.0L) is + denormal. + [TEST_LDOUBLE] (ceil_test, floor_test, llrint_test, llround_test, + rint_test, round_test, trunc_test): Add new tests. + + * sysdeps/powerpc/powerpc32/fpu/s_copysignl.S: New file. + * sysdeps/powerpc/powerpc32/fpu/s_fabs.S: New file. + * sysdeps/powerpc/powerpc32/fpu/s_fabsl.S: New file. + * sysdeps/powerpc/powerpc32/fpu/s_fdim.c: New file. + * sysdeps/powerpc/powerpc32/fpu/s_fmax.S: New file. + * sysdeps/powerpc/powerpc32/fpu/s_fmin.S: New file. + * sysdeps/powerpc/powerpc32/fpu/s_isnan.c: New file. + + * sysdeps/powerpc/powerpc64/fpu/s_ceill.S: New file. + * sysdeps/powerpc/powerpc64/fpu/s_copysignl.S: New file. + * sysdeps/powerpc/powerpc64/fpu/s_fabs.S: New file. + * sysdeps/powerpc/powerpc64/fpu/s_fabsl.S: New file. + * sysdeps/powerpc/powerpc64/fpu/s_fdim.c: New file. + * sysdeps/powerpc/powerpc64/fpu/s_floorl.S: New file. + * sysdeps/powerpc/powerpc64/fpu/s_fmax.S: New file. + * sysdeps/powerpc/powerpc64/fpu/s_fmin.S: New file. + * sysdeps/powerpc/powerpc64/fpu/s_isnan.c: New file. + * sysdeps/powerpc/powerpc64/fpu/s_llrintl.S: New file. + * sysdeps/powerpc/powerpc64/fpu/s_llroundl.S: New file. + * sysdeps/powerpc/powerpc64/fpu/s_lrintl.S: New file. + * sysdeps/powerpc/powerpc64/fpu/s_lroundl.S: New file. + * sysdeps/powerpc/powerpc64/fpu/s_nearbyintl.S: New file. + * sysdeps/powerpc/powerpc64/fpu/s_rintl.S: New file. + * sysdeps/powerpc/powerpc64/fpu/s_roundl.S: New file. + * sysdeps/powerpc/powerpc64/fpu/s_truncl.S: New file. + + * sysdeps/unix/sysv/linux/powerpc/Implies: New file. + * sysdeps/unix/sysv/linux/powerpc/powerpc64/fpu/Implies: New file. + * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/Implies: New file. + * sysdeps/unix/sysv/linux/powerpc/configure.in: New file. + * sysdeps/unix/sysv/linux/powerpc/configure: New file. + * sysdeps/unix/sysv/linux/powerpc/bits/wordsize.h + (__LONG_DOUBLE_MATH_OPTIONAL): Define. + (__NO_LONG_DOUBLE_MATH): Define. + * sysdeps/unix/sysv/linux/powerpc/nldbl-abi.h: New file. + * sysdeps/powerpc/fpu/s_isnan.c: Include math_ldbl_opt.h. + * sysdeps/powerpc/powerpc64/fpu/s_ceil.S: Include math_ldbl_opt.h. + [LONG_DOUBLE_COMPAT] (ceill): Add compatibility symbols. + * sysdeps/powerpc/powerpc64/fpu/s_copysign.S: Include math_ldbl_opt.h. + [LONG_DOUBLE_COMPAT] (copysignl): Add compatibility symbols. + * sysdeps/powerpc/powerpc64/fpu/s_floor.S: Include math_ldbl_opt.h. + [LONG_DOUBLE_COMPAT] (floorl): Add compatibility symbols. + * sysdeps/powerpc/powerpc64/fpu/s_llrint.S: Include math_ldbl_opt.h. + [LONG_DOUBLE_COMPAT] (llrintl, lrintl): Add compatibility symbols. + * sysdeps/powerpc/powerpc64/fpu/s_llround.S: Include math_ldbl_opt.h. + [LONG_DOUBLE_COMPAT] (llroundl, lroundl): Add compatibility symbols. + * sysdeps/powerpc/powerpc64/fpu/s_rint.S: Include math_ldbl_opt.h. + [LONG_DOUBLE_COMPAT] (rintl): Add compatibility symbols. + * sysdeps/powerpc/powerpc64/fpu/s_round.S: Include math_ldbl_opt.h. + [LONG_DOUBLE_COMPAT] (roundl): Add compatibility symbols. + * sysdeps/powerpc/powerpc64/fpu/s_trunc.S: Include math_ldbl_opt.h. + [LONG_DOUBLE_COMPAT] (truncl): Add compatibility symbols. + * sysdeps/powerpc/powerpc32/fpu/s_ceil.S: Include math_ldbl_opt.h. + [LONG_DOUBLE_COMPAT] (ceill): Add compatibility symbols. + * sysdeps/powerpc/powerpc32/fpu/s_copysign.S: Include math_ldbl_opt.h. + [LONG_DOUBLE_COMPAT] (copysignl): Add compatibility symbols. + * sysdeps/powerpc/powerpc32/fpu/s_floor.S: Include math_ldbl_opt.h. + [LONG_DOUBLE_COMPAT] (floorl): Add compatibility symbols. + * sysdeps/powerpc/powerpc32/fpu/s_lrint.S: Include math_ldbl_opt.h. + [LONG_DOUBLE_COMPAT] (lrintl): Add compatibility symbols. + * sysdeps/powerpc/powerpc32/fpu/s_llrint.c: Include math_ldbl_opt.h. + [LONG_DOUBLE_COMPAT] (llrintl): Add compatibility symbols. + * sysdeps/powerpc/powerpc32/fpu/s_lround.S: Include math_ldbl_opt.h. + [LONG_DOUBLE_COMPAT] (lroundl): Add compatibility symbols. + * sysdeps/powerpc/powerpc32/fpu/s_rint.S: Include math_ldbl_opt.h. + [LONG_DOUBLE_COMPAT] (rintl): Add compatibility symbols. + * sysdeps/powerpc/powerpc32/fpu/s_round.S: Include math_ldbl_opt.h. + [LONG_DOUBLE_COMPAT] (roundl): Add compatibility symbols. + * sysdeps/powerpc/powerpc32/fpu/s_trunc.S: Include math_ldbl_opt.h. + [LONG_DOUBLE_COMPAT] (truncl): Add compatibility symbols. + + * misc/qefgcvt_r.c [LDBL_MIN_10_EXP == -291] (FLOAT_MIN_10_NORM): New. + + * sysdeps/powerpc/fpu/bits/mathdef.h (__NO_LONG_DOUBLE_MATH): Remove. + * sysdeps/powerpc/Implies: Add ieee754/ldbl-128ibm. + * sysdeps/powerpc/powerpc32/Implies: Remove powerpc/soft-fp. + * sysdeps/ieee754/ldbl-128ibm/Makefile: New file. + * sysdeps/ieee754/ldbl-128ibm/e_acoshl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/e_acosl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/e_asinl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/e_atan2l.c: New file. + * sysdeps/ieee754/ldbl-128ibm/e_atanhl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/e_coshl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/e_expl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/e_fmodl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c: New file. + * sysdeps/ieee754/ldbl-128ibm/e_hypotl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/e_j0l.c: New file. + * sysdeps/ieee754/ldbl-128ibm/e_j1l.c: New file. + * sysdeps/ieee754/ldbl-128ibm/e_jnl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/e_lgammal_r.c: New file. + * sysdeps/ieee754/ldbl-128ibm/e_log10l.c: New file. + * sysdeps/ieee754/ldbl-128ibm/e_log2l.c: New file. + * sysdeps/ieee754/ldbl-128ibm/e_logl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/e_powl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/e_rem_pio2l.c: New file. + * sysdeps/ieee754/ldbl-128ibm/e_remainderl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/e_sinhl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/e_sqrtl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/ieee754.h: New file. + * sysdeps/ieee754/ldbl-128ibm/k_cosl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/k_sincosl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/k_sinl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/k_tanl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c: New file. + * sysdeps/ieee754/ldbl-128ibm/math_ldbl.h: New file. + * sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/printf_fphex.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_asinhl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_atanl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_cbrtl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_cosl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_erfl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_expm1l.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_fabsl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_finitel.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_fpclassifyl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_frexpl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_ilogbl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_isinfl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_isnanl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_log1pl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_logbl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_modfl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_remquol.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_rintl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_scalblnl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_scalbnl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_signbitl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_sincosl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_sinl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_tanhl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_tanl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_truncl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/strtold_l.c: New file. + * sysdeps/ieee754/ldbl-128ibm/t_sincosl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/w_expl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_copysignl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_floorl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_llrintl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_llroundl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_roundl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_ceill.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_lrintl.c: New file. + * sysdeps/ieee754/ldbl-128ibm/s_lroundl.c: New file. + + * sysdeps/ieee754/ldbl-128/e_powl.c: Fix old comment. + 2006-01-22 Aurelien Jarno * sysdeps/gnu/errlist-compat.awk: Reduce required number of symbols in diff --git a/math/libm-test.inc b/math/libm-test.inc index d4b0de6..3d72bbf 100644 --- a/math/libm-test.inc +++ b/math/libm-test.inc @@ -22,7 +22,7 @@ This file is processed by a perl script. The resulting file has to be included by a master file that defines: - Makros: + Macros: FUNC(function): converts general function name (like cos) to name with correct suffix (e.g. cosl or cosf) MATHCONST(x): like FUNC but for constants (e.g convert 0.0 to 0.0L) @@ -498,7 +498,7 @@ check_float_internal (const char *test_name, FLOAT computed, FLOAT expected, && computed == 0.0 && expected == 0.0 && signbit(computed) != signbit (expected)) ok = 0; - else if (ulp == 0.0 || (ulp <= max_ulp && !ignore_max_ulp)) + else if (ulp <= 0.5 || (ulp <= max_ulp && !ignore_max_ulp)) ok = 1; else { @@ -1631,6 +1631,51 @@ ceil_test (void) TEST_f_f (ceil, 0.25, 1.0); TEST_f_f (ceil, -0.25, minus_zero); +#ifdef TEST_LDOUBLE + /* The result can only be represented in long double. */ + TEST_f_f (ceil, 4503599627370495.5L, 4503599627370496.0L); + TEST_f_f (ceil, 4503599627370496.25L, 4503599627370497.0L); + TEST_f_f (ceil, 4503599627370496.5L, 4503599627370497.0L); + TEST_f_f (ceil, 4503599627370496.75L, 4503599627370497.0L); + TEST_f_f (ceil, 4503599627370497.5L, 4503599627370498.0L); + + TEST_f_f (ceil, -4503599627370495.5L, -4503599627370495.0L); + TEST_f_f (ceil, -4503599627370496.25L, -4503599627370496.0L); + TEST_f_f (ceil, -4503599627370496.5L, -4503599627370496.0L); + TEST_f_f (ceil, -4503599627370496.75L, -4503599627370496.0L); + TEST_f_f (ceil, -4503599627370497.5L, -4503599627370497.0L); + + TEST_f_f (ceil, 9007199254740991.5L, 9007199254740992.0L); + TEST_f_f (ceil, 9007199254740992.25L, 9007199254740993.0L); + TEST_f_f (ceil, 9007199254740992.5L, 9007199254740993.0L); + TEST_f_f (ceil, 9007199254740992.75L, 9007199254740993.0L); + TEST_f_f (ceil, 9007199254740993.5L, 9007199254740994.0L); + + TEST_f_f (ceil, -9007199254740991.5L, -9007199254740991.0L); + TEST_f_f (ceil, -9007199254740992.25L, -9007199254740992.0L); + TEST_f_f (ceil, -9007199254740992.5L, -9007199254740992.0L); + TEST_f_f (ceil, -9007199254740992.75L, -9007199254740992.0L); + TEST_f_f (ceil, -9007199254740993.5L, -9007199254740993.0L); + + TEST_f_f (ceil, 72057594037927935.5L, 72057594037927936.0L); + TEST_f_f (ceil, 72057594037927936.25L, 72057594037927937.0L); + TEST_f_f (ceil, 72057594037927936.5L, 72057594037927937.0L); + TEST_f_f (ceil, 72057594037927936.75L, 72057594037927937.0L); + TEST_f_f (ceil, 72057594037927937.5L, 72057594037927938.0L); + + TEST_f_f (ceil, -72057594037927935.5L, -72057594037927935.0L); + TEST_f_f (ceil, -72057594037927936.25L, -72057594037927936.0L); + TEST_f_f (ceil, -72057594037927936.5L, -72057594037927936.0L); + TEST_f_f (ceil, -72057594037927936.75L, -72057594037927936.0L); + TEST_f_f (ceil, -72057594037927937.5L, -72057594037927937.0L); + + TEST_f_f (ceil, 10141204801825835211973625643007.5L, 10141204801825835211973625643008.0L); + TEST_f_f (ceil, 10141204801825835211973625643008.25L, 10141204801825835211973625643009.0L); + TEST_f_f (ceil, 10141204801825835211973625643008.5L, 10141204801825835211973625643009.0L); + TEST_f_f (ceil, 10141204801825835211973625643008.75L, 10141204801825835211973625643009.0L); + TEST_f_f (ceil, 10141204801825835211973625643009.5L, 10141204801825835211973625643010.0L); +#endif + END (ceil); } @@ -2389,7 +2434,9 @@ erfc_test (void) TEST_f_f (erfc, 4.125L, 0.542340079956506600531223408575531062e-8L); #ifdef TEST_LDOUBLE /* The result can only be represented in long double. */ +# if LDBL_MIN_10_EXP < -319 TEST_f_f (erfc, 27.0L, 0.523704892378925568501606768284954709e-318L); +# endif #endif END (erfc); @@ -2584,6 +2631,52 @@ floor_test (void) TEST_f_f (floor, 0.25, 0.0); TEST_f_f (floor, -0.25, -1.0); + +#ifdef TEST_LDOUBLE + /* The result can only be represented in long double. */ + TEST_f_f (floor, 4503599627370495.5L, 4503599627370495.0L); + TEST_f_f (floor, 4503599627370496.25L, 4503599627370496.0L); + TEST_f_f (floor, 4503599627370496.5L, 4503599627370496.0L); + TEST_f_f (floor, 4503599627370496.75L, 4503599627370496.0L); + TEST_f_f (floor, 4503599627370497.5L, 4503599627370497.0L); + + TEST_f_f (floor, -4503599627370495.5L, -4503599627370496.0L); + TEST_f_f (floor, -4503599627370496.25L, -4503599627370497.0L); + TEST_f_f (floor, -4503599627370496.5L, -4503599627370497.0L); + TEST_f_f (floor, -4503599627370496.75L, -4503599627370497.0L); + TEST_f_f (floor, -4503599627370497.5L, -4503599627370498.0L); + + TEST_f_f (floor, 9007199254740991.5L, 9007199254740991.0L); + TEST_f_f (floor, 9007199254740992.25L, 9007199254740992.0L); + TEST_f_f (floor, 9007199254740992.5L, 9007199254740992.0L); + TEST_f_f (floor, 9007199254740992.75L, 9007199254740992.0L); + TEST_f_f (floor, 9007199254740993.5L, 9007199254740993.0L); + + TEST_f_f (floor, -9007199254740991.5L, -9007199254740992.0L); + TEST_f_f (floor, -9007199254740992.25L, -9007199254740993.0L); + TEST_f_f (floor, -9007199254740992.5L, -9007199254740993.0L); + TEST_f_f (floor, -9007199254740992.75L, -9007199254740993.0L); + TEST_f_f (floor, -9007199254740993.5L, -9007199254740994.0L); + + TEST_f_f (floor, 72057594037927935.5L, 72057594037927935.0L); + TEST_f_f (floor, 72057594037927936.25L, 72057594037927936.0L); + TEST_f_f (floor, 72057594037927936.5L, 72057594037927936.0L); + TEST_f_f (floor, 72057594037927936.75L, 72057594037927936.0L); + TEST_f_f (floor, 72057594037927937.5L, 72057594037927937.0L); + + TEST_f_f (floor, -72057594037927935.5L, -72057594037927936.0L); + TEST_f_f (floor, -72057594037927936.25L, -72057594037927937.0L); + TEST_f_f (floor, -72057594037927936.5L, -72057594037927937.0L); + TEST_f_f (floor, -72057594037927936.75L, -72057594037927937.0L); + TEST_f_f (floor, -72057594037927937.5L, -72057594037927938.0L); + + TEST_f_f (floor, 10141204801825835211973625643007.5L, 10141204801825835211973625643007.0L); + TEST_f_f (floor, 10141204801825835211973625643008.25L, 10141204801825835211973625643008.0L); + TEST_f_f (floor, 10141204801825835211973625643008.5L, 10141204801825835211973625643008.0L); + TEST_f_f (floor, 10141204801825835211973625643008.75L, 10141204801825835211973625643008.0L); + TEST_f_f (floor, 10141204801825835211973625643009.5L, 10141204801825835211973625643009.0L); +#endif + END (floor); } @@ -3164,6 +3257,44 @@ llrint_test (void) TEST_f_L (llrint, 36028797018963968.0, 36028797018963968LL); /* 0x100000000000000 */ TEST_f_L (llrint, 72057594037927936.0, 72057594037927936LL); +#ifdef TEST_LDOUBLE + /* The input can only be represented in long double. */ + TEST_f_L (llrint, 4503599627370495.5L, 4503599627370496LL); + TEST_f_L (llrint, 4503599627370496.25L, 4503599627370496LL); + TEST_f_L (llrint, 4503599627370496.5L, 4503599627370496LL); + TEST_f_L (llrint, 4503599627370496.75L, 4503599627370497LL); + TEST_f_L (llrint, 4503599627370497.5L, 4503599627370498LL); + + TEST_f_L (llrint, -4503599627370495.5L, -4503599627370496LL); + TEST_f_L (llrint, -4503599627370496.25L, -4503599627370496LL); + TEST_f_L (llrint, -4503599627370496.5L, -4503599627370496LL); + TEST_f_L (llrint, -4503599627370496.75L, -4503599627370497LL); + TEST_f_L (llrint, -4503599627370497.5L, -4503599627370498LL); + + TEST_f_L (llrint, 9007199254740991.5L, 9007199254740992LL); + TEST_f_L (llrint, 9007199254740992.25L, 9007199254740992LL); + TEST_f_L (llrint, 9007199254740992.5L, 9007199254740992LL); + TEST_f_L (llrint, 9007199254740992.75L, 9007199254740993LL); + TEST_f_L (llrint, 9007199254740993.5L, 9007199254740994LL); + + TEST_f_L (llrint, -9007199254740991.5L, -9007199254740992LL); + TEST_f_L (llrint, -9007199254740992.25L, -9007199254740992LL); + TEST_f_L (llrint, -9007199254740992.5L, -9007199254740992LL); + TEST_f_L (llrint, -9007199254740992.75L, -9007199254740993LL); + TEST_f_L (llrint, -9007199254740993.5L, -9007199254740994LL); + + TEST_f_L (llrint, 72057594037927935.5L, 72057594037927936LL); + TEST_f_L (llrint, 72057594037927936.25L, 72057594037927936LL); + TEST_f_L (llrint, 72057594037927936.5L, 72057594037927936LL); + TEST_f_L (llrint, 72057594037927936.75L, 72057594037927937LL); + TEST_f_L (llrint, 72057594037927937.5L, 72057594037927938LL); + + TEST_f_L (llrint, -72057594037927935.5L, -72057594037927936LL); + TEST_f_L (llrint, -72057594037927936.25L, -72057594037927936LL); + TEST_f_L (llrint, -72057594037927936.5L, -72057594037927936LL); + TEST_f_L (llrint, -72057594037927936.75L, -72057594037927937LL); + TEST_f_L (llrint, -72057594037927937.5L, -72057594037927938LL); +#endif END (llrint); } @@ -3398,6 +3529,45 @@ llround_test (void) TEST_f_L (llround, 8589934591.5, 8589934592LL); #endif +#ifdef TEST_LDOUBLE + /* The input can only be represented in long double. */ + TEST_f_L (llround, 4503599627370495.5L, 4503599627370496LL); + TEST_f_L (llround, 4503599627370496.25L, 4503599627370496LL); + TEST_f_L (llround, 4503599627370496.5L, 4503599627370497LL); + TEST_f_L (llround, 4503599627370496.75L, 4503599627370497LL); + TEST_f_L (llround, 4503599627370497.5L, 4503599627370498LL); + + TEST_f_L (llround, -4503599627370495.5L, -4503599627370496LL); + TEST_f_L (llround, -4503599627370496.25L, -4503599627370496LL); + TEST_f_L (llround, -4503599627370496.5L, -4503599627370497LL); + TEST_f_L (llround, -4503599627370496.75L, -4503599627370497LL); + TEST_f_L (llround, -4503599627370497.5L, -4503599627370498LL); + + TEST_f_L (llround, 9007199254740991.5L, 9007199254740992LL); + TEST_f_L (llround, 9007199254740992.25L, 9007199254740992LL); + TEST_f_L (llround, 9007199254740992.5L, 9007199254740993LL); + TEST_f_L (llround, 9007199254740992.75L, 9007199254740993LL); + TEST_f_L (llround, 9007199254740993.5L, 9007199254740994LL); + + TEST_f_L (llround, -9007199254740991.5L, -9007199254740992LL); + TEST_f_L (llround, -9007199254740992.25L, -9007199254740992LL); + TEST_f_L (llround, -9007199254740992.5L, -9007199254740993LL); + TEST_f_L (llround, -9007199254740992.75L, -9007199254740993LL); + TEST_f_L (llround, -9007199254740993.5L, -9007199254740994LL); + + TEST_f_L (llround, 72057594037927935.5L, 72057594037927936LL); + TEST_f_L (llround, 72057594037927936.25L, 72057594037927936LL); + TEST_f_L (llround, 72057594037927936.5L, 72057594037927937LL); + TEST_f_L (llround, 72057594037927936.75L, 72057594037927937LL); + TEST_f_L (llround, 72057594037927937.5L, 72057594037927938LL); + + TEST_f_L (llround, -72057594037927935.5L, -72057594037927936LL); + TEST_f_L (llround, -72057594037927936.25L, -72057594037927936LL); + TEST_f_L (llround, -72057594037927936.5L, -72057594037927937LL); + TEST_f_L (llround, -72057594037927936.75L, -72057594037927937LL); + TEST_f_L (llround, -72057594037927937.5L, -72057594037927938LL); +#endif + END (llround); } @@ -3794,6 +3964,50 @@ rint_test (void) TEST_f_f (rint, -2.5, -2.0); TEST_f_f (rint, -3.5, -4.0); TEST_f_f (rint, -4.5, -4.0); +#ifdef TEST_LDOUBLE + /* The result can only be represented in long double. */ + TEST_f_f (rint, 4503599627370495.5L, 4503599627370496.0L); + TEST_f_f (rint, 4503599627370496.25L, 4503599627370496.0L); + TEST_f_f (rint, 4503599627370496.5L, 4503599627370496.0L); + TEST_f_f (rint, 4503599627370496.75L, 4503599627370497.0L); + TEST_f_f (rint, 4503599627370497.5L, 4503599627370498.0L); + + TEST_f_f (rint, -4503599627370495.5L, -4503599627370496.0L); + TEST_f_f (rint, -4503599627370496.25L, -4503599627370496.0L); + TEST_f_f (rint, -4503599627370496.5L, -4503599627370496.0L); + TEST_f_f (rint, -4503599627370496.75L, -4503599627370497.0L); + TEST_f_f (rint, -4503599627370497.5L, -4503599627370498.0L); + + TEST_f_f (rint, 9007199254740991.5L, 9007199254740992.0L); + TEST_f_f (rint, 9007199254740992.25L, 9007199254740992.0L); + TEST_f_f (rint, 9007199254740992.5L, 9007199254740992.0L); + TEST_f_f (rint, 9007199254740992.75L, 9007199254740993.0L); + TEST_f_f (rint, 9007199254740993.5L, 9007199254740994.0L); + + TEST_f_f (rint, -9007199254740991.5L, -9007199254740992.0L); + TEST_f_f (rint, -9007199254740992.25L, -9007199254740992.0L); + TEST_f_f (rint, -9007199254740992.5L, -9007199254740992.0L); + TEST_f_f (rint, -9007199254740992.75L, -9007199254740993.0L); + TEST_f_f (rint, -9007199254740993.5L, -9007199254740994.0L); + + TEST_f_f (rint, 72057594037927935.5L, 72057594037927936.0L); + TEST_f_f (rint, 72057594037927936.25L, 72057594037927936.0L); + TEST_f_f (rint, 72057594037927936.5L, 72057594037927936.0L); + TEST_f_f (rint, 72057594037927936.75L, 72057594037927937.0L); + TEST_f_f (rint, 72057594037927937.5L, 72057594037927938.0L); + + TEST_f_f (rint, -72057594037927935.5L, -72057594037927936.0L); + TEST_f_f (rint, -72057594037927936.25L, -72057594037927936.0L); + TEST_f_f (rint, -72057594037927936.5L, -72057594037927936.0L); + TEST_f_f (rint, -72057594037927936.75L, -72057594037927937.0L); + TEST_f_f (rint, -72057594037927937.5L, -72057594037927938.0L); + + TEST_f_f (rint, 10141204801825835211973625643007.5L, 10141204801825835211973625643008.0L); + TEST_f_f (rint, 10141204801825835211973625643008.25L, 10141204801825835211973625643008.0L); + TEST_f_f (rint, 10141204801825835211973625643008.5L, 10141204801825835211973625643008.0L); + TEST_f_f (rint, 10141204801825835211973625643008.75L, 10141204801825835211973625643009.0L); + TEST_f_f (rint, 10141204801825835211973625643009.5L, 10141204801825835211973625643010.0L); +#endif END (rint); } @@ -3924,6 +4138,51 @@ round_test (void) TEST_f_f (round, 2097152.5, 2097153); TEST_f_f (round, -2097152.5, -2097153); +#ifdef TEST_LDOUBLE + /* The result can only be represented in long double. */ + TEST_f_f (round, 4503599627370495.5L, 4503599627370496.0L); + TEST_f_f (round, 4503599627370496.25L, 4503599627370496.0L); + TEST_f_f (round, 4503599627370496.5L, 4503599627370497.0L); + TEST_f_f (round, 4503599627370496.75L, 4503599627370497.0L); + TEST_f_f (round, 4503599627370497.5L, 4503599627370498.0L); + + TEST_f_f (round, -4503599627370495.5L, -4503599627370496.0L); + TEST_f_f (round, -4503599627370496.25L, -4503599627370496.0L); + TEST_f_f (round, -4503599627370496.5L, -4503599627370497.0L); + TEST_f_f (round, -4503599627370496.75L, -4503599627370497.0L); + TEST_f_f (round, -4503599627370497.5L, -4503599627370498.0L); + + TEST_f_f (round, 9007199254740991.5L, 9007199254740992.0L); + TEST_f_f (round, 9007199254740992.25L, 9007199254740992.0L); + TEST_f_f (round, 9007199254740992.5L, 9007199254740993.0L); + TEST_f_f (round, 9007199254740992.75L, 9007199254740993.0L); + TEST_f_f (round, 9007199254740993.5L, 9007199254740994.0L); + + TEST_f_f (round, -9007199254740991.5L, -9007199254740992.0L); + TEST_f_f (round, -9007199254740992.25L, -9007199254740992.0L); + TEST_f_f (round, -9007199254740992.5L, -9007199254740993.0L); + TEST_f_f (round, -9007199254740992.75L, -9007199254740993.0L); + TEST_f_f (round, -9007199254740993.5L, -9007199254740994.0L); + + TEST_f_f (round, 72057594037927935.5L, 72057594037927936.0L); + TEST_f_f (round, 72057594037927936.25L, 72057594037927936.0L); + TEST_f_f (round, 72057594037927936.5L, 72057594037927937.0L); + TEST_f_f (round, 72057594037927936.75L, 72057594037927937.0L); + TEST_f_f (round, 72057594037927937.5L, 72057594037927938.0L); + + TEST_f_f (round, -72057594037927935.5L, -72057594037927936.0L); + TEST_f_f (round, -72057594037927936.25L, -72057594037927936.0L); + TEST_f_f (round, -72057594037927936.5L, -72057594037927937.0L); + TEST_f_f (round, -72057594037927936.75L, -72057594037927937.0L); + TEST_f_f (round, -72057594037927937.5L, -72057594037927938.0L); + + TEST_f_f (round, 10141204801825835211973625643007.5L, 10141204801825835211973625643008.0L); + TEST_f_f (round, 10141204801825835211973625643008.25L, 10141204801825835211973625643008.0L); + TEST_f_f (round, 10141204801825835211973625643008.5L, 10141204801825835211973625643009.0L); + TEST_f_f (round, 10141204801825835211973625643008.75L, 10141204801825835211973625643009.0L); + TEST_f_f (round, 10141204801825835211973625643009.5L, 10141204801825835211973625643010.0L); +#endif + END (round); } @@ -4291,6 +4550,50 @@ trunc_test (void) TEST_f_f (trunc, 4294967296.625L, 4294967296.0L); TEST_f_f (trunc, -4294967296.625L, -4294967296.0L); +#ifdef TEST_LDOUBLE + /* The result can only be represented in long double. */ + TEST_f_f (trunc, 4503599627370495.5L, 4503599627370495.0L); + TEST_f_f (trunc, 4503599627370496.25L, 4503599627370496.0L); + TEST_f_f (trunc, 4503599627370496.5L, 4503599627370496.0L); + TEST_f_f (trunc, 4503599627370496.75L, 4503599627370496.0L); + TEST_f_f (trunc, 4503599627370497.5L, 4503599627370497.0L); + + TEST_f_f (trunc, -4503599627370495.5L, -4503599627370495.0L); + TEST_f_f (trunc, -4503599627370496.25L, -4503599627370496.0L); + TEST_f_f (trunc, -4503599627370496.5L, -4503599627370496.0L); + TEST_f_f (trunc, -4503599627370496.75L, -4503599627370496.0L); + TEST_f_f (trunc, -4503599627370497.5L, -4503599627370497.0L); + + TEST_f_f (trunc, 9007199254740991.5L, 9007199254740991.0L); + TEST_f_f (trunc, 9007199254740992.25L, 9007199254740992.0L); + TEST_f_f (trunc, 9007199254740992.5L, 9007199254740992.0L); + TEST_f_f (trunc, 9007199254740992.75L, 9007199254740992.0L); + TEST_f_f (trunc, 9007199254740993.5L, 9007199254740993.0L); + + TEST_f_f (trunc, -9007199254740991.5L, -9007199254740991.0L); + TEST_f_f (trunc, -9007199254740992.25L, -9007199254740992.0L); + TEST_f_f (trunc, -9007199254740992.5L, -9007199254740992.0L); + TEST_f_f (trunc, -9007199254740992.75L, -9007199254740992.0L); + TEST_f_f (trunc, -9007199254740993.5L, -9007199254740993.0L); + + TEST_f_f (trunc, 72057594037927935.5L, 72057594037927935.0L); + TEST_f_f (trunc, 72057594037927936.25L, 72057594037927936.0L); + TEST_f_f (trunc, 72057594037927936.5L, 72057594037927936.0L); + TEST_f_f (trunc, 72057594037927936.75L, 72057594037927936.0L); + TEST_f_f (trunc, 72057594037927937.5L, 72057594037927937.0L); + + TEST_f_f (trunc, -72057594037927935.5L, -72057594037927935.0L); + TEST_f_f (trunc, -72057594037927936.25L, -72057594037927936.0L); + TEST_f_f (trunc, -72057594037927936.5L, -72057594037927936.0L); + TEST_f_f (trunc, -72057594037927936.75L, -72057594037927936.0L); + TEST_f_f (trunc, -72057594037927937.5L, -72057594037927937.0L); + + TEST_f_f (trunc, 10141204801825835211973625643007.5L, 10141204801825835211973625643007.0L); + TEST_f_f (trunc, 10141204801825835211973625643008.25L, 10141204801825835211973625643008.0L); + TEST_f_f (trunc, 10141204801825835211973625643008.5L, 10141204801825835211973625643008.0L); + TEST_f_f (trunc, 10141204801825835211973625643008.75L, 10141204801825835211973625643008.0L); + TEST_f_f (trunc, 10141204801825835211973625643009.5L, 10141204801825835211973625643009.0L); +#endif END (trunc); } diff --git a/misc/qefgcvt_r.c b/misc/qefgcvt_r.c index d5b2a79..a03ff74 100644 --- a/misc/qefgcvt_r.c +++ b/misc/qefgcvt_r.c @@ -43,6 +43,8 @@ #endif #if LDBL_MIN_10_EXP == -37 # define FLOAT_MIN_10_NORM 1.0e-37L +#elif LDBL_MIN_10_EXP == -291 +# define FLOAT_MIN_10_NORM 1.0e-291L #elif LDBL_MIN_10_EXP == -307 # define FLOAT_MIN_10_NORM 1.0e-307L #elif LDBL_MIN_10_EXP == -4931 diff --git a/sysdeps/ieee754/ldbl-128/e_powl.c b/sysdeps/ieee754/ldbl-128/e_powl.c index 18bf237..ba7e27b 100644 --- a/sysdeps/ieee754/ldbl-128/e_powl.c +++ b/sysdeps/ieee754/ldbl-128/e_powl.c @@ -220,7 +220,7 @@ __ieee754_powl (x, y) { if (((ix - 0x3fff0000) | p.parts32.w1 | p.parts32.w2 | p.parts32.w3) == 0) - return y - y; /* inf**+-1 is NaN */ + return y - y; /* +-1**inf is NaN */ else if (ix >= 0x3fff0000) /* (|x|>1)**+-inf = inf,0 */ return (hy >= 0) ? y : zero; else /* (|x|<1)**-,+inf = inf,0 */ diff --git a/sysdeps/ieee754/ldbl-128ibm/Makefile b/sysdeps/ieee754/ldbl-128ibm/Makefile new file mode 100644 index 0000000..8e1e2e6 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/Makefile @@ -0,0 +1,5 @@ +# The`long double' type is a distinct type we support if +# -mlong-double-128 option is used (or when it becomes a default +# when -mlong-double-64 is not used). +long-double-fcts = yes +sysdep-CFLAGS += -mlong-double-128 diff --git a/sysdeps/ieee754/ldbl-128ibm/e_acoshl.c b/sysdeps/ieee754/ldbl-128ibm/e_acoshl.c new file mode 100644 index 0000000..00576c7 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/e_acoshl.c @@ -0,0 +1,69 @@ +/* @(#)e_acosh.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: e_acosh.c,v 1.9 1995/05/12 04:57:18 jtc Exp $"; +#endif + +/* __ieee754_acosh(x) + * Method : + * Based on + * acosh(x) = log [ x + sqrt(x*x-1) ] + * we have + * acosh(x) := log(x)+ln2, if x is large; else + * acosh(x) := log(2x-1/(sqrt(x*x-1)+x)) if x>2; else + * acosh(x) := log1p(t+sqrt(2.0*t+t*t)); where t=x-1. + * + * Special cases: + * acosh(x) is NaN with signal if x<1. + * acosh(NaN) is NaN without signal. + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const long double +#else +static long double +#endif +one = 1.0L, +ln2 = 6.93147180559945286227e-01L; /* 0x3FE62E42, 0xFEFA39EF */ + +#ifdef __STDC__ + long double __ieee754_acoshl(long double x) +#else + long double __ieee754_acoshl(x) + long double x; +#endif +{ + long double t; + int64_t hx; + u_int64_t lx; + GET_LDOUBLE_WORDS64(hx,lx,x); + if(hx<0x3ff0000000000000LL) { /* x < 1 */ + return (x-x)/(x-x); + } else if(hx >=0x41b0000000000000LL) { /* x > 2**28 */ + if(hx >=0x7ff0000000000000LL) { /* x is inf of NaN */ + return x+x; + } else + return __ieee754_logl(x)+ln2; /* acosh(huge)=log(2x) */ + } else if (((hx-0x3ff0000000000000LL)|(lx&0x7fffffffffffffffLL))==0) { + return 0.0; /* acosh(1) = 0 */ + } else if (hx > 0x4000000000000000LL) { /* 2**28 > x > 2 */ + t=x*x; + return __ieee754_logl(2.0*x-one/(x+__ieee754_sqrtl(t-one))); + } else { /* 1 + and are incorporated herein by permission of the author. The author + reserves the right to distribute this material elsewhere under different + copying permissions. These modifications are distributed here under + the following terms: + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* __ieee754_acosl(x) + * Method : + * acos(x) = pi/2 - asin(x) + * acos(-x) = pi/2 + asin(x) + * For |x| <= 0.375 + * acos(x) = pi/2 - asin(x) + * Between .375 and .5 the approximation is + * acos(0.4375 + x) = acos(0.4375) + x P(x) / Q(x) + * Between .5 and .625 the approximation is + * acos(0.5625 + x) = acos(0.5625) + x rS(x) / sS(x) + * For x > 0.625, + * acos(x) = 2 asin(sqrt((1-x)/2)) + * computed with an extended precision square root in the leading term. + * For x < -0.625 + * acos(x) = pi - 2 asin(sqrt((1-|x|)/2)) + * + * Special cases: + * if x is NaN, return x itself; + * if |x|>1, return NaN with invalid signal. + * + * Functions needed: __ieee754_sqrtl. + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const long double +#else +static long double +#endif + one = 1.0L, + pio2_hi = 1.5707963267948966192313216916397514420986L, + pio2_lo = 4.3359050650618905123985220130216759843812E-35L, + + /* acos(0.5625 + x) = acos(0.5625) + x rS(x) / sS(x) + -0.0625 <= x <= 0.0625 + peak relative error 3.3e-35 */ + + rS0 = 5.619049346208901520945464704848780243887E0L, + rS1 = -4.460504162777731472539175700169871920352E1L, + rS2 = 1.317669505315409261479577040530751477488E2L, + rS3 = -1.626532582423661989632442410808596009227E2L, + rS4 = 3.144806644195158614904369445440583873264E1L, + rS5 = 9.806674443470740708765165604769099559553E1L, + rS6 = -5.708468492052010816555762842394927806920E1L, + rS7 = -1.396540499232262112248553357962639431922E1L, + rS8 = 1.126243289311910363001762058295832610344E1L, + rS9 = 4.956179821329901954211277873774472383512E-1L, + rS10 = -3.313227657082367169241333738391762525780E-1L, + + sS0 = -4.645814742084009935700221277307007679325E0L, + sS1 = 3.879074822457694323970438316317961918430E1L, + sS2 = -1.221986588013474694623973554726201001066E2L, + sS3 = 1.658821150347718105012079876756201905822E2L, + sS4 = -4.804379630977558197953176474426239748977E1L, + sS5 = -1.004296417397316948114344573811562952793E2L, + sS6 = 7.530281592861320234941101403870010111138E1L, + sS7 = 1.270735595411673647119592092304357226607E1L, + sS8 = -1.815144839646376500705105967064792930282E1L, + sS9 = -7.821597334910963922204235247786840828217E-2L, + /* 1.000000000000000000000000000000000000000E0 */ + + acosr5625 = 9.7338991014954640492751132535550279812151E-1L, + pimacosr5625 = 2.1682027434402468335351320579240000860757E0L, + + /* acos(0.4375 + x) = acos(0.4375) + x rS(x) / sS(x) + -0.0625 <= x <= 0.0625 + peak relative error 2.1e-35 */ + + P0 = 2.177690192235413635229046633751390484892E0L, + P1 = -2.848698225706605746657192566166142909573E1L, + P2 = 1.040076477655245590871244795403659880304E2L, + P3 = -1.400087608918906358323551402881238180553E2L, + P4 = 2.221047917671449176051896400503615543757E1L, + P5 = 9.643714856395587663736110523917499638702E1L, + P6 = -5.158406639829833829027457284942389079196E1L, + P7 = -1.578651828337585944715290382181219741813E1L, + P8 = 1.093632715903802870546857764647931045906E1L, + P9 = 5.448925479898460003048760932274085300103E-1L, + P10 = -3.315886001095605268470690485170092986337E-1L, + Q0 = -1.958219113487162405143608843774587557016E0L, + Q1 = 2.614577866876185080678907676023269360520E1L, + Q2 = -9.990858606464150981009763389881793660938E1L, + Q3 = 1.443958741356995763628660823395334281596E2L, + Q4 = -3.206441012484232867657763518369723873129E1L, + Q5 = -1.048560885341833443564920145642588991492E2L, + Q6 = 6.745883931909770880159915641984874746358E1L, + Q7 = 1.806809656342804436118449982647641392951E1L, + Q8 = -1.770150690652438294290020775359580915464E1L, + Q9 = -5.659156469628629327045433069052560211164E-1L, + /* 1.000000000000000000000000000000000000000E0 */ + + acosr4375 = 1.1179797320499710475919903296900511518755E0L, + pimacosr4375 = 2.0236129215398221908706530535894517323217E0L, + + /* asin(x) = x + x^3 pS(x^2) / qS(x^2) + 0 <= x <= 0.5 + peak relative error 1.9e-35 */ + pS0 = -8.358099012470680544198472400254596543711E2L, + pS1 = 3.674973957689619490312782828051860366493E3L, + pS2 = -6.730729094812979665807581609853656623219E3L, + pS3 = 6.643843795209060298375552684423454077633E3L, + pS4 = -3.817341990928606692235481812252049415993E3L, + pS5 = 1.284635388402653715636722822195716476156E3L, + pS6 = -2.410736125231549204856567737329112037867E2L, + pS7 = 2.219191969382402856557594215833622156220E1L, + pS8 = -7.249056260830627156600112195061001036533E-1L, + pS9 = 1.055923570937755300061509030361395604448E-3L, + + qS0 = -5.014859407482408326519083440151745519205E3L, + qS1 = 2.430653047950480068881028451580393430537E4L, + qS2 = -4.997904737193653607449250593976069726962E4L, + qS3 = 5.675712336110456923807959930107347511086E4L, + qS4 = -3.881523118339661268482937768522572588022E4L, + qS5 = 1.634202194895541569749717032234510811216E4L, + qS6 = -4.151452662440709301601820849901296953752E3L, + qS7 = 5.956050864057192019085175976175695342168E2L, + qS8 = -4.175375777334867025769346564600396877176E1L; + /* 1.000000000000000000000000000000000000000E0 */ + +#ifdef __STDC__ +long double +__ieee754_acosl (long double x) +#else +long double +__ieee754_acosl (x) + long double x; +#endif +{ + long double z, r, w, p, q, s, t, f2; + int32_t ix, sign; + ieee854_long_double_shape_type u; + + u.value = x; + sign = u.parts32.w0; + ix = sign & 0x7fffffff; + u.parts32.w0 = ix; /* |x| */ + if (ix >= 0x3ff00000) /* |x| >= 1 */ + { + if (ix == 0x3ff00000 + && (u.parts32.w1 | (u.parts32.w2&0x7fffffff) | u.parts32.w3) == 0) + { /* |x| == 1 */ + if ((sign & 0x80000000) == 0) + return 0.0; /* acos(1) = 0 */ + else + return (2.0 * pio2_hi) + (2.0 * pio2_lo); /* acos(-1)= pi */ + } + return (x - x) / (x - x); /* acos(|x| > 1) is NaN */ + } + else if (ix < 0x3fe00000) /* |x| < 0.5 */ + { + if (ix < 0x3c600000) /* |x| < 2**-57 */ + return pio2_hi + pio2_lo; + if (ix < 0x3fde0000) /* |x| < .4375 */ + { + /* Arcsine of x. */ + z = x * x; + p = (((((((((pS9 * z + + pS8) * z + + pS7) * z + + pS6) * z + + pS5) * z + + pS4) * z + + pS3) * z + + pS2) * z + + pS1) * z + + pS0) * z; + q = (((((((( z + + qS8) * z + + qS7) * z + + qS6) * z + + qS5) * z + + qS4) * z + + qS3) * z + + qS2) * z + + qS1) * z + + qS0; + r = x + x * p / q; + z = pio2_hi - (r - pio2_lo); + return z; + } + /* .4375 <= |x| < .5 */ + t = u.value - 0.4375L; + p = ((((((((((P10 * t + + P9) * t + + P8) * t + + P7) * t + + P6) * t + + P5) * t + + P4) * t + + P3) * t + + P2) * t + + P1) * t + + P0) * t; + + q = (((((((((t + + Q9) * t + + Q8) * t + + Q7) * t + + Q6) * t + + Q5) * t + + Q4) * t + + Q3) * t + + Q2) * t + + Q1) * t + + Q0; + r = p / q; + if (sign & 0x80000000) + r = pimacosr4375 - r; + else + r = acosr4375 + r; + return r; + } + else if (ix < 0x3fe40000) /* |x| < 0.625 */ + { + t = u.value - 0.5625L; + p = ((((((((((rS10 * t + + rS9) * t + + rS8) * t + + rS7) * t + + rS6) * t + + rS5) * t + + rS4) * t + + rS3) * t + + rS2) * t + + rS1) * t + + rS0) * t; + + q = (((((((((t + + sS9) * t + + sS8) * t + + sS7) * t + + sS6) * t + + sS5) * t + + sS4) * t + + sS3) * t + + sS2) * t + + sS1) * t + + sS0; + if (sign & 0x80000000) + r = pimacosr5625 - p / q; + else + r = acosr5625 + p / q; + return r; + } + else + { /* |x| >= .625 */ + z = (one - u.value) * 0.5; + s = __ieee754_sqrtl (z); + /* Compute an extended precision square root from + the Newton iteration s -> 0.5 * (s + z / s). + The change w from s to the improved value is + w = 0.5 * (s + z / s) - s = (s^2 + z)/2s - s = (z - s^2)/2s. + Express s = f1 + f2 where f1 * f1 is exactly representable. + w = (z - s^2)/2s = (z - f1^2 - 2 f1 f2 - f2^2)/2s . + s + w has extended precision. */ + u.value = s; + u.parts32.w2 = 0; + u.parts32.w3 = 0; + f2 = s - u.value; + w = z - u.value * u.value; + w = w - 2.0 * u.value * f2; + w = w - f2 * f2; + w = w / (2.0 * s); + /* Arcsine of s. */ + p = (((((((((pS9 * z + + pS8) * z + + pS7) * z + + pS6) * z + + pS5) * z + + pS4) * z + + pS3) * z + + pS2) * z + + pS1) * z + + pS0) * z; + q = (((((((( z + + qS8) * z + + qS7) * z + + qS6) * z + + qS5) * z + + qS4) * z + + qS3) * z + + qS2) * z + + qS1) * z + + qS0; + r = s + (w + s * p / q); + + if (sign & 0x80000000) + w = pio2_hi + (pio2_lo - r); + else + w = r; + return 2.0 * w; + } +} diff --git a/sysdeps/ieee754/ldbl-128ibm/e_asinl.c b/sysdeps/ieee754/ldbl-128ibm/e_asinl.c new file mode 100644 index 0000000..3696694 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/e_asinl.c @@ -0,0 +1,265 @@ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + Long double expansions are + Copyright (C) 2001 Stephen L. Moshier + and are incorporated herein by permission of the author. The author + reserves the right to distribute this material elsewhere under different + copying permissions. These modifications are distributed here under the + following terms: + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* __ieee754_asin(x) + * Method : + * Since asin(x) = x + x^3/6 + x^5*3/40 + x^7*15/336 + ... + * we approximate asin(x) on [0,0.5] by + * asin(x) = x + x*x^2*R(x^2) + * Between .5 and .625 the approximation is + * asin(0.5625 + x) = asin(0.5625) + x rS(x) / sS(x) + * For x in [0.625,1] + * asin(x) = pi/2-2*asin(sqrt((1-x)/2)) + * Let y = (1-x), z = y/2, s := sqrt(z), and pio2_hi+pio2_lo=pi/2; + * then for x>0.98 + * asin(x) = pi/2 - 2*(s+s*z*R(z)) + * = pio2_hi - (2*(s+s*z*R(z)) - pio2_lo) + * For x<=0.98, let pio4_hi = pio2_hi/2, then + * f = hi part of s; + * c = sqrt(z) - f = (z-f*f)/(s+f) ...f+c=sqrt(z) + * and + * asin(x) = pi/2 - 2*(s+s*z*R(z)) + * = pio4_hi+(pio4-2s)-(2s*z*R(z)-pio2_lo) + * = pio4_hi+(pio4-2f)-(2s*z*R(z)-(pio2_lo+2c)) + * + * Special cases: + * if x is NaN, return x itself; + * if |x|>1, return NaN with invalid signal. + * + */ + + +#include "math.h" +#include "math_private.h" +long double sqrtl (long double); + +#ifdef __STDC__ +static const long double +#else +static long double +#endif + one = 1.0L, + huge = 1.0e+300L, + pio2_hi = 1.5707963267948966192313216916397514420986L, + pio2_lo = 4.3359050650618905123985220130216759843812E-35L, + pio4_hi = 7.8539816339744830961566084581987569936977E-1L, + + /* coefficient for R(x^2) */ + + /* asin(x) = x + x^3 pS(x^2) / qS(x^2) + 0 <= x <= 0.5 + peak relative error 1.9e-35 */ + pS0 = -8.358099012470680544198472400254596543711E2L, + pS1 = 3.674973957689619490312782828051860366493E3L, + pS2 = -6.730729094812979665807581609853656623219E3L, + pS3 = 6.643843795209060298375552684423454077633E3L, + pS4 = -3.817341990928606692235481812252049415993E3L, + pS5 = 1.284635388402653715636722822195716476156E3L, + pS6 = -2.410736125231549204856567737329112037867E2L, + pS7 = 2.219191969382402856557594215833622156220E1L, + pS8 = -7.249056260830627156600112195061001036533E-1L, + pS9 = 1.055923570937755300061509030361395604448E-3L, + + qS0 = -5.014859407482408326519083440151745519205E3L, + qS1 = 2.430653047950480068881028451580393430537E4L, + qS2 = -4.997904737193653607449250593976069726962E4L, + qS3 = 5.675712336110456923807959930107347511086E4L, + qS4 = -3.881523118339661268482937768522572588022E4L, + qS5 = 1.634202194895541569749717032234510811216E4L, + qS6 = -4.151452662440709301601820849901296953752E3L, + qS7 = 5.956050864057192019085175976175695342168E2L, + qS8 = -4.175375777334867025769346564600396877176E1L, + /* 1.000000000000000000000000000000000000000E0 */ + + /* asin(0.5625 + x) = asin(0.5625) + x rS(x) / sS(x) + -0.0625 <= x <= 0.0625 + peak relative error 3.3e-35 */ + rS0 = -5.619049346208901520945464704848780243887E0L, + rS1 = 4.460504162777731472539175700169871920352E1L, + rS2 = -1.317669505315409261479577040530751477488E2L, + rS3 = 1.626532582423661989632442410808596009227E2L, + rS4 = -3.144806644195158614904369445440583873264E1L, + rS5 = -9.806674443470740708765165604769099559553E1L, + rS6 = 5.708468492052010816555762842394927806920E1L, + rS7 = 1.396540499232262112248553357962639431922E1L, + rS8 = -1.126243289311910363001762058295832610344E1L, + rS9 = -4.956179821329901954211277873774472383512E-1L, + rS10 = 3.313227657082367169241333738391762525780E-1L, + + sS0 = -4.645814742084009935700221277307007679325E0L, + sS1 = 3.879074822457694323970438316317961918430E1L, + sS2 = -1.221986588013474694623973554726201001066E2L, + sS3 = 1.658821150347718105012079876756201905822E2L, + sS4 = -4.804379630977558197953176474426239748977E1L, + sS5 = -1.004296417397316948114344573811562952793E2L, + sS6 = 7.530281592861320234941101403870010111138E1L, + sS7 = 1.270735595411673647119592092304357226607E1L, + sS8 = -1.815144839646376500705105967064792930282E1L, + sS9 = -7.821597334910963922204235247786840828217E-2L, + /* 1.000000000000000000000000000000000000000E0 */ + + asinr5625 = 5.9740641664535021430381036628424864397707E-1L; + + + +#ifdef __STDC__ +long double +__ieee754_asinl (long double x) +#else +double +__ieee754_asinl (x) + long double x; +#endif +{ + long double t, w, p, q, c, r, s; + int32_t ix, sign, flag; + ieee854_long_double_shape_type u; + + flag = 0; + u.value = x; + sign = u.parts32.w0; + ix = sign & 0x7fffffff; + u.parts32.w0 = ix; /* |x| */ + if (ix >= 0x3ff00000) /* |x|>= 1 */ + { + if (ix == 0x3ff00000 + && (u.parts32.w1 | (u.parts32.w2 & 0x7fffffff) | u.parts32.w3) == 0) + /* asin(1)=+-pi/2 with inexact */ + return x * pio2_hi + x * pio2_lo; + return (x - x) / (x - x); /* asin(|x|>1) is NaN */ + } + else if (ix < 0x3fe00000) /* |x| < 0.5 */ + { + if (ix < 0x3c600000) /* |x| < 2**-57 */ + { + if (huge + x > one) + return x; /* return x with inexact if x!=0 */ + } + else + { + t = x * x; + /* Mark to use pS, qS later on. */ + flag = 1; + } + } + else if (ix < 0x3fe40000) /* 0.625 */ + { + t = u.value - 0.5625; + p = ((((((((((rS10 * t + + rS9) * t + + rS8) * t + + rS7) * t + + rS6) * t + + rS5) * t + + rS4) * t + + rS3) * t + + rS2) * t + + rS1) * t + + rS0) * t; + + q = ((((((((( t + + sS9) * t + + sS8) * t + + sS7) * t + + sS6) * t + + sS5) * t + + sS4) * t + + sS3) * t + + sS2) * t + + sS1) * t + + sS0; + t = asinr5625 + p / q; + if ((sign & 0x80000000) == 0) + return t; + else + return -t; + } + else + { + /* 1 > |x| >= 0.625 */ + w = one - u.value; + t = w * 0.5; + } + + p = (((((((((pS9 * t + + pS8) * t + + pS7) * t + + pS6) * t + + pS5) * t + + pS4) * t + + pS3) * t + + pS2) * t + + pS1) * t + + pS0) * t; + + q = (((((((( t + + qS8) * t + + qS7) * t + + qS6) * t + + qS5) * t + + qS4) * t + + qS3) * t + + qS2) * t + + qS1) * t + + qS0; + + if (flag) /* 2^-57 < |x| < 0.5 */ + { + w = p / q; + return x + x * w; + } + + s = __ieee754_sqrtl (t); + if (ix >= 0x3fef3333) /* |x| > 0.975 */ + { + w = p / q; + t = pio2_hi - (2.0 * (s + s * w) - pio2_lo); + } + else + { + u.value = s; + u.parts32.w3 = 0; + u.parts32.w2 = 0; + w = u.value; + c = (t - w * w) / (s + w); + r = p / q; + p = 2.0 * s * r - (pio2_lo - 2.0 * c); + q = pio4_hi - 2.0 * w; + t = pio4_hi - (p - q); + } + + if ((sign & 0x80000000) == 0) + return t; + else + return -t; +} diff --git a/sysdeps/ieee754/ldbl-128ibm/e_atan2l.c b/sysdeps/ieee754/ldbl-128ibm/e_atan2l.c new file mode 100644 index 0000000..a4bb53d --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/e_atan2l.c @@ -0,0 +1,124 @@ +/* e_atan2l.c -- long double version of e_atan2.c. + * Conversion to long double by Jakub Jelinek, jj@ultra.linux.cz. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* __ieee754_atan2l(y,x) + * Method : + * 1. Reduce y to positive by atan2l(y,x)=-atan2l(-y,x). + * 2. Reduce x to positive by (if x and y are unexceptional): + * ARG (x+iy) = arctan(y/x) ... if x > 0, + * ARG (x+iy) = pi - arctan[y/(-x)] ... if x < 0, + * + * Special cases: + * + * ATAN2((anything), NaN ) is NaN; + * ATAN2(NAN , (anything) ) is NaN; + * ATAN2(+-0, +(anything but NaN)) is +-0 ; + * ATAN2(+-0, -(anything but NaN)) is +-pi ; + * ATAN2(+-(anything but 0 and NaN), 0) is +-pi/2; + * ATAN2(+-(anything but INF and NaN), +INF) is +-0 ; + * ATAN2(+-(anything but INF and NaN), -INF) is +-pi; + * ATAN2(+-INF,+INF ) is +-pi/4 ; + * ATAN2(+-INF,-INF ) is +-3pi/4; + * ATAN2(+-INF, (anything but,0,NaN, and INF)) is +-pi/2; + * + * Constants: + * The hexadecimal values are the intended ones for the following + * constants. The decimal values may be used, provided that the + * compiler will convert from decimal to binary accurately enough + * to produce the hexadecimal values shown. + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const long double +#else +static long double +#endif +tiny = 1.0e-300L, +zero = 0.0, +pi_o_4 = 7.85398163397448309615660845819875699e-01L, /* 3ffe921fb54442d18469898cc51701b8 */ +pi_o_2 = 1.57079632679489661923132169163975140e+00L, /* 3fff921fb54442d18469898cc51701b8 */ +pi = 3.14159265358979323846264338327950280e+00L, /* 4000921fb54442d18469898cc51701b8 */ +pi_lo = 8.67181013012378102479704402604335225e-35L; /* 3f8dcd129024e088a67cc74020bbea64 */ + +#ifdef __STDC__ + long double __ieee754_atan2l(long double y, long double x) +#else + long double __ieee754_atan2l(y,x) + long double y,x; +#endif +{ + long double z; + int64_t k,m,hx,hy,ix,iy; + u_int64_t lx,ly; + + GET_LDOUBLE_WORDS64(hx,lx,x); + ix = hx&0x7fffffffffffffffLL; + GET_LDOUBLE_WORDS64(hy,ly,y); + iy = hy&0x7fffffffffffffffLL; + if(((ix)>0x7ff0000000000000LL)|| + ((iy)>0x7ff0000000000000LL)) /* x or y is NaN */ + return x+y; + if(((hx-0x3ff0000000000000LL))==0) return __atanl(y); /* x=1.0L */ + m = ((hy>>63)&1)|((hx>>62)&2); /* 2*sign(x)+sign(y) */ + + /* when y = 0 */ + if((iy|(ly&0x7fffffffffffffffLL))==0) { + switch(m) { + case 0: + case 1: return y; /* atan(+-0,+anything)=+-0 */ + case 2: return pi+tiny;/* atan(+0,-anything) = pi */ + case 3: return -pi-tiny;/* atan(-0,-anything) =-pi */ + } + } + /* when x = 0 */ + if((ix|(lx&0x7fffffffffffffff))==0) return (hy<0)? -pi_o_2-tiny: pi_o_2+tiny; + + /* when x is INF */ + if(ix==0x7ff0000000000000LL) { + if(iy==0x7ff0000000000000LL) { + switch(m) { + case 0: return pi_o_4+tiny;/* atan(+INF,+INF) */ + case 1: return -pi_o_4-tiny;/* atan(-INF,+INF) */ + case 2: return 3.0L*pi_o_4+tiny;/*atan(+INF,-INF)*/ + case 3: return -3.0L*pi_o_4-tiny;/*atan(-INF,-INF)*/ + } + } else { + switch(m) { + case 0: return zero ; /* atan(+...,+INF) */ + case 1: return -zero ; /* atan(-...,+INF) */ + case 2: return pi+tiny ; /* atan(+...,-INF) */ + case 3: return -pi-tiny ; /* atan(-...,-INF) */ + } + } + } + /* when y is INF */ + if(iy==0x7ff0000000000000LL) return (hy<0)? -pi_o_2-tiny: pi_o_2+tiny; + + /* compute y/x */ + k = (iy-ix)>>52; + if(k > 120) z=pi_o_2+0.5L*pi_lo; /* |y/x| > 2**120 */ + else if(hx<0&&k<-120) z=0.0L; /* |y|/x < -2**120 */ + else z=__atanl(fabsl(y/x)); /* safe to do y/x */ + switch (m) { + case 0: return z ; /* atan(+,+) */ + case 1: return -z ; /* atan(-,+) */ + case 2: return pi-(z-pi_lo);/* atan(+,-) */ + default: /* case 3 */ + return (z-pi_lo)-pi;/* atan(-,-) */ + } +} diff --git a/sysdeps/ieee754/ldbl-128ibm/e_atanhl.c b/sysdeps/ieee754/ldbl-128ibm/e_atanhl.c new file mode 100644 index 0000000..a801bd6 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/e_atanhl.c @@ -0,0 +1,79 @@ +/* @(#)e_atanh.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: e_atanh.c,v 1.8 1995/05/10 20:44:55 jtc Exp $"; +#endif + +/* __ieee754_atanh(x) + * Method : + * 1.Reduced x to positive by atanh(-x) = -atanh(x) + * 2.For x>=0.5 + * 1 2x x + * atanh(x) = --- * log(1 + -------) = 0.5 * log1p(2 * --------) + * 2 1 - x 1 - x + * + * For x<0.5 + * atanh(x) = 0.5*log1p(2x+2x*x/(1-x)) + * + * Special cases: + * atanh(x) is NaN if |x| > 1 with signal; + * atanh(NaN) is that NaN with no signal; + * atanh(+-1) is +-INF with signal. + * + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const long double one = 1.0L, huge = 1e300L; +#else +static long double one = 1.0L, huge = 1e300L; +#endif + +#ifdef __STDC__ +static const long double zero = 0.0L; +#else +static long double zero = 0.0L; +#endif + +#ifdef __STDC__ + long double __ieee754_atanhl(long double x) +#else + long double __ieee754_atanhl(x) + long double x; +#endif +{ + long double t; + int64_t hx,ix; + u_int64_t lx; + GET_LDOUBLE_WORDS64(hx,lx,x); + ix = hx&0x7fffffffffffffffLL; + if (ix >= 0x3ff0000000000000LL) { /* |x|>=1 */ + if (ix > 0x3ff0000000000000LL) + return (x-x)/(x-x); + t = fabsl (x); + if (t > one) + return (x-x)/(x-x); + if (t == one) + return x/zero; + } + if(ix<0x3e20000000000000LL&&(huge+x)>zero) return x; /* x<2**-29 */ + x = fabsl (x); + if(ix<0x3fe0000000000000LL) { /* x < 0.5 */ + t = x+x; + t = 0.5*__log1pl(t+t*x/(one-x)); + } else + t = 0.5*__log1pl((x+x)/(one-x)); + if(hx>=0) return t; else return -t; +} diff --git a/sysdeps/ieee754/ldbl-128ibm/e_coshl.c b/sysdeps/ieee754/ldbl-128ibm/e_coshl.c new file mode 100644 index 0000000..73cb478 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/e_coshl.c @@ -0,0 +1,90 @@ +/* @(#)e_cosh.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: e_cosh.c,v 1.7 1995/05/10 20:44:58 jtc Exp $"; +#endif + +/* __ieee754_cosh(x) + * Method : + * mathematically cosh(x) if defined to be (exp(x)+exp(-x))/2 + * 1. Replace x by |x| (cosh(x) = cosh(-x)). + * 2. + * [ exp(x) - 1 ]^2 + * 0 <= x <= ln2/2 : cosh(x) := 1 + ------------------- + * 2*exp(x) + * + * exp(x) + 1/exp(x) + * ln2/2 <= x <= 22 : cosh(x) := ------------------- + * 2 + * 22 <= x <= lnovft : cosh(x) := exp(x)/2 + * lnovft <= x <= ln2ovft: cosh(x) := exp(x/2)/2 * exp(x/2) + * ln2ovft < x : cosh(x) := huge*huge (overflow) + * + * Special cases: + * cosh(x) is |x| if x is +INF, -INF, or NaN. + * only cosh(0)=1 is exact for finite x. + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const long double one = 1.0L, half=0.5L, huge = 1.0e300L; +#else +static long double one = 1.0L, half=0.5L, huge = 1.0e300L; +#endif + +#ifdef __STDC__ + long double __ieee754_coshl(long double x) +#else + long double __ieee754_coshl(x) + long double x; +#endif +{ + long double t,w; + int64_t ix; + + /* High word of |x|. */ + GET_LDOUBLE_MSW64(ix,x); + ix &= 0x7fffffffffffffffLL; + + /* x is INF or NaN */ + if(ix>=0x7ff0000000000000LL) return x*x; + + /* |x| in [0,0.5*ln2], return 1+expm1(|x|)^2/(2*exp(|x|)) */ + if(ix<0x3fd62e42fefa39efLL) { + t = __expm1l(fabsl(x)); + w = one+t; + if (ix<0x3c80000000000000LL) return w; /* cosh(tiny) = 1 */ + return one+(t*t)/(w+w); + } + + /* |x| in [0.5*ln2,22], return (exp(|x|)+1/exp(|x|)/2; */ + if (ix < 0x4036000000000000LL) { + t = __ieee754_expl(fabsl(x)); + return half*t+half/t; + } + + /* |x| in [22, log(maxdouble)] return half*exp(|x|) */ + if (ix < 0x40862e42fefa39efLL) return half*__ieee754_expl(fabsl(x)); + + /* |x| in [log(maxdouble), overflowthresold] */ + if (ix < 0x408633ce8fb9f87dLL) { + w = __ieee754_expl(half*fabsl(x)); + t = half*w; + return t*w; + } + + /* |x| > overflowthresold, cosh(x) overflow */ + return huge*huge; +} diff --git a/sysdeps/ieee754/ldbl-128ibm/e_expl.c b/sysdeps/ieee754/ldbl-128ibm/e_expl.c new file mode 100644 index 0000000..3c4088f --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/e_expl.c @@ -0,0 +1,257 @@ +/* Quad-precision floating point e^x. + Copyright (C) 1999,2004,2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek + Partly based on double-precision code + by Geoffrey Keating + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* The basic design here is from + Abraham Ziv, "Fast Evaluation of Elementary Mathematical Functions with + Correctly Rounded Last Bit", ACM Trans. Math. Soft., 17 (3), September 1991, + pp. 410-423. + + We work with number pairs where the first number is the high part and + the second one is the low part. Arithmetic with the high part numbers must + be exact, without any roundoff errors. + + The input value, X, is written as + X = n * ln(2)_0 + arg1[t1]_0 + arg2[t2]_0 + x + - n * ln(2)_1 + arg1[t1]_1 + arg2[t2]_1 + xl + + where: + - n is an integer, 16384 >= n >= -16495; + - ln(2)_0 is the first 93 bits of ln(2), and |ln(2)_0-ln(2)-ln(2)_1| < 2^-205 + - t1 is an integer, 89 >= t1 >= -89 + - t2 is an integer, 65 >= t2 >= -65 + - |arg1[t1]-t1/256.0| < 2^-53 + - |arg2[t2]-t2/32768.0| < 2^-53 + - x + xl is whatever is left, |x + xl| < 2^-16 + 2^-53 + + Then e^x is approximated as + + e^x = 2^n_1 ( 2^n_0 e^(arg1[t1]_0 + arg1[t1]_1) e^(arg2[t2]_0 + arg2[t2]_1) + + 2^n_0 e^(arg1[t1]_0 + arg1[t1]_1) e^(arg2[t2]_0 + arg2[t2]_1) + * p (x + xl + n * ln(2)_1)) + where: + - p(x) is a polynomial approximating e(x)-1 + - e^(arg1[t1]_0 + arg1[t1]_1) is obtained from a table + - e^(arg2[t2]_0 + arg2[t2]_1) likewise + - n_1 + n_0 = n, so that |n_0| < -LDBL_MIN_EXP-1. + + If it happens that n_1 == 0 (this is the usual case), that multiplication + is omitted. + */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#include +#include +#include +#include +#include +#include +#include + +static const long double C[] = { +/* Smallest integer x for which e^x overflows. */ +#define himark C[0] + 709.08956571282405153382846025171462914L, + +/* Largest integer x for which e^x underflows. */ +#define lomark C[1] +-709.08956571282405153382846025171462914L, + +/* 3x2^96 */ +#define THREEp96 C[2] + 59421121885698253195157962752.0L, + +/* 3x2^103 */ +#define THREEp103 C[3] + 30423614405477505635920876929024.0L, + +/* 3x2^111 */ +#define THREEp111 C[4] + 7788445287802241442795744493830144.0L, + +/* 1/ln(2) */ +#define M_1_LN2 C[5] + 1.44269504088896340735992468100189204L, + +/* first 93 bits of ln(2) */ +#define M_LN2_0 C[6] + 0.693147180559945309417232121457981864L, + +/* ln2_0 - ln(2) */ +#define M_LN2_1 C[7] +-1.94704509238074995158795957333327386E-31L, + +/* very small number */ +#define TINY C[8] + 1.0e-308L, + +/* 2^16383 */ +#define TWO1023 C[9] + 8.988465674311579538646525953945123668E+307L, + +/* 256 */ +#define TWO8 C[10] + 256.0L, + +/* 32768 */ +#define TWO15 C[11] + 32768.0L, + +/* Chebyshev polynom coeficients for (exp(x)-1)/x */ +#define P1 C[12] +#define P2 C[13] +#define P3 C[14] +#define P4 C[15] +#define P5 C[16] +#define P6 C[17] + 0.5L, + 1.66666666666666666666666666666666683E-01L, + 4.16666666666666666666654902320001674E-02L, + 8.33333333333333333333314659767198461E-03L, + 1.38888888889899438565058018857254025E-03L, + 1.98412698413981650382436541785404286E-04L, +}; + +long double +__ieee754_expl (long double x) +{ + /* Check for usual case. */ + if (isless (x, himark) && isgreater (x, lomark)) + { + int tval1, tval2, unsafe, n_i, exponent2; + long double x22, n, result, xl; + union ibm_extended_long_double ex2_u, scale_u; + fenv_t oldenv; + + feholdexcept (&oldenv); +#ifdef FE_TONEAREST + fesetround (FE_TONEAREST); +#endif + + n = roundl(x*M_1_LN2); + x = x-n*M_LN2_0; + xl = n*M_LN2_1; + + tval1 = roundl(x*TWO8); + x -= __expl_table[T_EXPL_ARG1+2*tval1]; + xl -= __expl_table[T_EXPL_ARG1+2*tval1+1]; + + tval2 = roundl(x*TWO15); + x -= __expl_table[T_EXPL_ARG2+2*tval2]; + xl -= __expl_table[T_EXPL_ARG2+2*tval2+1]; + + x = x + xl; + + /* Compute ex2 = 2^n_0 e^(argtable[tval1]) e^(argtable[tval2]). */ + ex2_u.d = __expl_table[T_EXPL_RES1 + tval1] + * __expl_table[T_EXPL_RES2 + tval2]; + n_i = (int)n; + /* 'unsafe' is 1 iff n_1 != 0. */ + unsafe = fabsl(n_i) >= -LDBL_MIN_EXP - 1; + ex2_u.ieee.exponent += n_i >> unsafe; + /* Fortunately, there are no subnormal lowpart doubles in + __expl_table, only normal values and zeros. + But after scaling it can be subnormal. */ + exponent2 = ex2_u.ieee.exponent2 + (n_i >> unsafe); + if (ex2_u.ieee.exponent2 == 0) + /* assert ((ex2_u.ieee.mantissa2|ex2_u.ieee.mantissa3) == 0) */; + else if (exponent2 > 0) + ex2_u.ieee.exponent2 = exponent2; + else if (exponent2 <= -54) + { + ex2_u.ieee.exponent2 = 0; + ex2_u.ieee.mantissa2 = 0; + ex2_u.ieee.mantissa3 = 0; + } + else + { + static const double + two54 = 1.80143985094819840000e+16, /* 4350000000000000 */ + twom54 = 5.55111512312578270212e-17; /* 3C90000000000000 */ + ex2_u.dd[1] *= two54; + ex2_u.ieee.exponent2 += n_i >> unsafe; + ex2_u.dd[1] *= twom54; + } + + /* Compute scale = 2^n_1. */ + scale_u.d = 1.0L; + scale_u.ieee.exponent += n_i - (n_i >> unsafe); + + /* Approximate e^x2 - 1, using a seventh-degree polynomial, + with maximum error in [-2^-16-2^-53,2^-16+2^-53] + less than 4.8e-39. */ + x22 = x + x*x*(P1+x*(P2+x*(P3+x*(P4+x*(P5+x*P6))))); + + /* Return result. */ + fesetenv (&oldenv); + + result = x22 * ex2_u.d + ex2_u.d; + + /* Now we can test whether the result is ultimate or if we are unsure. + In the later case we should probably call a mpn based routine to give + the ultimate result. + Empirically, this routine is already ultimate in about 99.9986% of + cases, the test below for the round to nearest case will be false + in ~ 99.9963% of cases. + Without proc2 routine maximum error which has been seen is + 0.5000262 ulp. + + union ieee854_long_double ex3_u; + + #ifdef FE_TONEAREST + fesetround (FE_TONEAREST); + #endif + ex3_u.d = (result - ex2_u.d) - x22 * ex2_u.d; + ex2_u.d = result; + ex3_u.ieee.exponent += LDBL_MANT_DIG + 15 + IEEE854_LONG_DOUBLE_BIAS + - ex2_u.ieee.exponent; + n_i = abs (ex3_u.d); + n_i = (n_i + 1) / 2; + fesetenv (&oldenv); + #ifdef FE_TONEAREST + if (fegetround () == FE_TONEAREST) + n_i -= 0x4000; + #endif + if (!n_i) { + return __ieee754_expl_proc2 (origx); + } + */ + if (!unsafe) + return result; + else + return result * scale_u.d; + } + /* Exceptional cases: */ + else if (isless (x, himark)) + { + if (__isinfl (x)) + /* e^-inf == 0, with no error. */ + return 0; + else + /* Underflow */ + return TINY * TINY; + } + else + /* Return x, if x is a NaN or Inf; or overflow, otherwise. */ + return TWO1023*x; +} diff --git a/sysdeps/ieee754/ldbl-128ibm/e_fmodl.c b/sysdeps/ieee754/ldbl-128ibm/e_fmodl.c new file mode 100644 index 0000000..9666873 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/e_fmodl.c @@ -0,0 +1,145 @@ +/* e_fmodl.c -- long double version of e_fmod.c. + * Conversion to IEEE quad long double by Jakub Jelinek, jj@ultra.linux.cz. + */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * __ieee754_fmodl(x,y) + * Return x mod y in exact arithmetic + * Method: shift and subtract + */ + +#include "math.h" +#include "math_private.h" +#include + +#ifdef __STDC__ +static const long double one = 1.0, Zero[] = {0.0, -0.0,}; +#else +static long double one = 1.0, Zero[] = {0.0, -0.0,}; +#endif + +#ifdef __STDC__ + long double __ieee754_fmodl(long double x, long double y) +#else + long double __ieee754_fmodl(x,y) + long double x,y; +#endif +{ + int64_t n,hx,hy,hz,ix,iy,sx,i; + u_int64_t lx,ly,lz; + int temp; + + GET_LDOUBLE_WORDS64(hx,lx,x); + GET_LDOUBLE_WORDS64(hy,ly,y); + sx = hx&0x8000000000000000ULL; /* sign of x */ + hx ^=sx; /* |x| */ + hy &= 0x7fffffffffffffffLL; /* |y| */ + + /* purge off exception values */ + if((hy|(ly&0x7fffffffffffffff))==0||(hx>=0x7ff0000000000000LL)|| /* y=0,or x not finite */ + (hy>0x7ff0000000000000LL)) /* or y is NaN */ + return (x*y)/(x*y); + if(hx<=hy) { + if((hx>63]; /* |x|=|y| return x*0*/ + } + + /* determine ix = ilogb(x) */ + if(hx<0x0010000000000000LL) { /* subnormal x */ + if(hx==0) { + for (ix = -1043, i=lx; i>0; i<<=1) ix -=1; + } else { + for (ix = -1022, i=hx<<19; i>0; i<<=1) ix -=1; + } + } else ix = (hx>>52)-0x3ff; + + /* determine iy = ilogb(y) */ + if(hy<0x0010000000000000LL) { /* subnormal y */ + if(hy==0) { + for (iy = -1043, i=ly; i>0; i<<=1) iy -=1; + } else { + for (iy = -1022, i=hy<<19; i>0; i<<=1) iy -=1; + } + } else iy = (hy>>52)-0x3ff; + + /* Make the IBM extended format 105 bit mantissa look like the ieee854 112 + bit mantissa so the following operatations will give the correct + result. */ + EXTRACT_IBM_EXTENDED_MANTISSA(hx, lx, temp, x); + EXTRACT_IBM_EXTENDED_MANTISSA(hy, ly, temp, y); + + /* set up {hx,lx}, {hy,ly} and align y to x */ + if(ix >= -1022) + hx = 0x0001000000000000LL|(0x0000ffffffffffffLL&hx); + else { /* subnormal x, shift x to normal */ + n = -1022-ix; + if(n<=63) { + hx = (hx<>(64-n)); + lx <<= n; + } else { + hx = lx<<(n-64); + lx = 0; + } + } + if(iy >= -1022) + hy = 0x0001000000000000LL|(0x0000ffffffffffffLL&hy); + else { /* subnormal y, shift y to normal */ + n = -1022-iy; + if(n<=63) { + hy = (hy<>(64-n)); + ly <<= n; + } else { + hy = ly<<(n-64); + ly = 0; + } + } + + /* fix point fmod */ + n = ix - iy; + while(n--) { + hz=hx-hy;lz=lx-ly; if(lx>63); lx = lx+lx;} + else { + if((hz|(lz&0x7fffffffffffffff))==0) /* return sign(x)*0 */ + return Zero[(u_int64_t)sx>>63]; + hx = hz+hz+(lz>>63); lx = lz+lz; + } + } + hz=hx-hy;lz=lx-ly; if(lx=0) {hx=hz;lx=lz;} + + /* convert back to floating value and restore the sign */ + if((hx|(lx&0x7fffffffffffffff))==0) /* return sign(x)*0 */ + return Zero[(u_int64_t)sx>>63]; + while(hx<0x0001000000000000LL) { /* normalize x */ + hx = hx+hx+(lx>>63); lx = lx+lx; + iy -= 1; + } + if(iy>= -1022) { /* normalize output */ + INSERT_IBM_EXTENDED_MANTISSA(x, (sx>>63), iy, hx, lx); + } else { /* subnormal output */ + n = -1022 - iy; + if(n<=48) { + lx = (lx>>n)|((u_int64_t)hx<<(64-n)); + hx >>= n; + } else if (n<=63) { + lx = (hx<<(64-n))|(lx>>n); hx = sx; + } else { + lx = hx>>(n-64); hx = sx; + } + INSERT_IBM_EXTENDED_MANTISSA(x, (sx>>63), iy, hx, lx); + x *= one; /* create necessary signal */ + } + return x; /* exact output */ +} diff --git a/sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c b/sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c new file mode 100644 index 0000000..03bcb21 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c @@ -0,0 +1,58 @@ +/* Implementation of gamma function according to ISO C. + Copyright (C) 1997,1999,2002,2004,2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997 and + Jakub Jelinek +#include + + +long double +__ieee754_gammal_r (long double x, int *signgamp) +{ + /* We don't have a real gamma implementation now. We'll use lgamma + and the exp function. But due to the required boundary + conditions we must check some values separately. */ + int64_t hx; + u_int64_t lx; + + GET_LDOUBLE_WORDS64 (hx, lx, x); + + if (((hx | lx) & 0x7fffffffffffffffLL) == 0) + { + /* Return value for x == 0 is Inf with divide by zero exception. */ + *signgamp = 0; + return 1.0 / x; + } + if (hx < 0 && (u_int64_t) hx < 0xfff0000000000000ULL && __rintl (x) == x) + { + /* Return value for integer x < 0 is NaN with invalid exception. */ + *signgamp = 0; + return (x - x) / (x - x); + } + if (hx == 0xfff0000000000000ULL) + { + /* x == -Inf. According to ISO this is NaN. */ + *signgamp = 0; + return x - x; + } + + /* XXX FIXME. */ + return __ieee754_expl (__ieee754_lgammal_r (x, signgamp)); +} diff --git a/sysdeps/ieee754/ldbl-128ibm/e_hypotl.c b/sysdeps/ieee754/ldbl-128ibm/e_hypotl.c new file mode 100644 index 0000000..4330f28 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/e_hypotl.c @@ -0,0 +1,131 @@ +/* @(#)e_hypotl.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: e_hypotl.c,v 1.9 1995/05/12 04:57:27 jtc Exp $"; +#endif + +/* __ieee754_hypotl(x,y) + * + * Method : + * If (assume round-to-nearest) z=x*x+y*y + * has error less than sqrtl(2)/2 ulp, than + * sqrtl(z) has error less than 1 ulp (exercise). + * + * So, compute sqrtl(x*x+y*y) with some care as + * follows to get the error below 1 ulp: + * + * Assume x>y>0; + * (if possible, set rounding to round-to-nearest) + * 1. if x > 2y use + * x1*x1+(y*y+(x2*(x+x1))) for x*x+y*y + * where x1 = x with lower 53 bits cleared, x2 = x-x1; else + * 2. if x <= 2y use + * t1*y1+((x-y)*(x-y)+(t1*y2+t2*y)) + * where t1 = 2x with lower 53 bits cleared, t2 = 2x-t1, + * y1= y with lower 53 bits chopped, y2 = y-y1. + * + * NOTE: scaling may be necessary if some argument is too + * large or too tiny + * + * Special cases: + * hypotl(x,y) is INF if x or y is +INF or -INF; else + * hypotl(x,y) is NAN if x or y is NAN. + * + * Accuracy: + * hypotl(x,y) returns sqrtl(x^2+y^2) with error less + * than 1 ulps (units in the last place) + */ + +#include "math.h" +#include "math_private.h" + +static const long double two600 = 0x1.0p+600L; +static const long double two1022 = 0x1.0p+1022L; + +#ifdef __STDC__ + long double __ieee754_hypotl(long double x, long double y) +#else + long double __ieee754_hypotl(x,y) + long double x, y; +#endif +{ + long double a,b,t1,t2,y1,y2,w,kld; + int64_t j,k,ha,hb; + + GET_LDOUBLE_MSW64(ha,x); + ha &= 0x7fffffffffffffffLL; + GET_LDOUBLE_MSW64(hb,y); + hb &= 0x7fffffffffffffffLL; + if(hb > ha) {a=y;b=x;j=ha; ha=hb;hb=j;} else {a=x;b=y;} + a = fabsl(a); /* a <- |a| */ + b = fabsl(b); /* b <- |b| */ + if((ha-hb)>0x3c0000000000000LL) {return a+b;} /* x/y > 2**60 */ + k=0; + kld = 1.0L; + if(ha > 0x5f30000000000000LL) { /* a>2**500 */ + if(ha >= 0x7ff0000000000000LL) { /* Inf or NaN */ + u_int64_t low; + w = a+b; /* for sNaN */ + GET_LDOUBLE_LSW64(low,a); + if(((ha&0xfffffffffffffLL)|(low&0x7fffffffffffffffLL))==0) + w = a; + GET_LDOUBLE_LSW64(low,b); + if(((hb^0x7ff0000000000000LL)|(low&0x7fffffffffffffffLL))==0) + w = b; + return w; + } + /* scale a and b by 2**-600 */ + ha -= 0x2580000000000000LL; hb -= 0x2580000000000000LL; k += 600; + a /= two600; + b /= two600; + k += 600; + kld = two600; + } + if(hb < 0x20b0000000000000LL) { /* b < 2**-500 */ + if(hb <= 0x000fffffffffffffLL) { /* subnormal b or 0 */ + u_int64_t low; + GET_LDOUBLE_LSW64(low,b); + if((hb|(low&0x7fffffffffffffffLL))==0) return a; + t1=two1022; /* t1=2^1022 */ + b *= t1; + a *= t1; + k -= 1022; + kld = kld / two1022; + } else { /* scale a and b by 2^600 */ + ha += 0x2580000000000000LL; /* a *= 2^600 */ + hb += 0x2580000000000000LL; /* b *= 2^600 */ + k -= 600; + a *= two600; + b *= two600; + kld = kld / two600; + } + } + /* medium size a and b */ + w = a-b; + if (w>b) { + SET_LDOUBLE_WORDS64(t1,ha,0); + t2 = a-t1; + w = __ieee754_sqrtl(t1*t1-(b*(-b)-t2*(a+t1))); + } else { + a = a+a; + SET_LDOUBLE_WORDS64(y1,hb,0); + y2 = b - y1; + SET_LDOUBLE_WORDS64(t1,ha+0x0010000000000000LL,0); + t2 = a - t1; + w = __ieee754_sqrtl(t1*y1-(w*(-w)-(t1*y2+t2*b))); + } + if(k!=0) + return w*kld; + else + return w; +} diff --git a/sysdeps/ieee754/ldbl-128ibm/e_j0l.c b/sysdeps/ieee754/ldbl-128ibm/e_j0l.c new file mode 100644 index 0000000..39a238a --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/e_j0l.c @@ -0,0 +1,3 @@ +/* Looks like we can use ieee854 e_j0l.c as is for IBM extended format. */ +#include + diff --git a/sysdeps/ieee754/ldbl-128ibm/e_j1l.c b/sysdeps/ieee754/ldbl-128ibm/e_j1l.c new file mode 100644 index 0000000..c86e24f --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/e_j1l.c @@ -0,0 +1,2 @@ +/* Looks like we can use ieee854 e_j1l.c as is for IBM extended format. */ +#include diff --git a/sysdeps/ieee754/ldbl-128ibm/e_jnl.c b/sysdeps/ieee754/ldbl-128ibm/e_jnl.c new file mode 100644 index 0000000..0eea745 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/e_jnl.c @@ -0,0 +1,402 @@ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* Modifications for 128-bit long double are + Copyright (C) 2001 Stephen L. Moshier + and are incorporated herein by permission of the author. The author + reserves the right to distribute this material elsewhere under different + copying permissions. These modifications are distributed here under + the following terms: + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* + * __ieee754_jn(n, x), __ieee754_yn(n, x) + * floating point Bessel's function of the 1st and 2nd kind + * of order n + * + * Special cases: + * y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal; + * y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal. + * Note 2. About jn(n,x), yn(n,x) + * For n=0, j0(x) is called, + * for n=1, j1(x) is called, + * for nx, a continued fraction approximation to + * j(n,x)/j(n-1,x) is evaluated and then backward + * recursion is used starting from a supposed value + * for j(n,x). The resulting value of j(0,x) is + * compared with the actual value to correct the + * supposed value of j(n,x). + * + * yn(n,x) is similar in all respects, except + * that forward recursion is used for all + * values of n>1. + * + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const long double +#else +static long double +#endif + invsqrtpi = 5.6418958354775628694807945156077258584405E-1L, + two = 2.0e0L, + one = 1.0e0L, + zero = 0.0L; + + +#ifdef __STDC__ +long double +__ieee754_jnl (int n, long double x) +#else +long double +__ieee754_jnl (n, x) + int n; + long double x; +#endif +{ + u_int32_t se; + int32_t i, ix, sgn; + long double a, b, temp, di; + long double z, w; + ieee854_long_double_shape_type u; + + + /* J(-n,x) = (-1)^n * J(n, x), J(n, -x) = (-1)^n * J(n, x) + * Thus, J(-n,x) = J(n,-x) + */ + + u.value = x; + se = u.parts32.w0; + ix = se & 0x7fffffff; + + /* if J(n,NaN) is NaN */ + if (ix >= 0x7ff00000) + { + if ((u.parts32.w0 & 0xfffff) | u.parts32.w1 + | (u.parts32.w2 & 0x7fffffff) | u.parts32.w3) + return x + x; + } + + if (n < 0) + { + n = -n; + x = -x; + se ^= 0x80000000; + } + if (n == 0) + return (__ieee754_j0l (x)); + if (n == 1) + return (__ieee754_j1l (x)); + sgn = (n & 1) & (se >> 31); /* even n -- 0, odd n -- sign(x) */ + x = fabsl (x); + + if (x == 0.0L || ix >= 0x7ff00000) /* if x is 0 or inf */ + b = zero; + else if ((long double) n <= x) + { + /* Safe to use J(n+1,x)=2n/x *J(n,x)-J(n-1,x) */ + if (ix >= 0x52d00000) + { /* x > 2**302 */ + + /* ??? Could use an expansion for large x here. */ + + /* (x >> n**2) + * Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi) + * Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi) + * Let s=sin(x), c=cos(x), + * xn=x-(2n+1)*pi/4, sqt2 = sqrt(2),then + * + * n sin(xn)*sqt2 cos(xn)*sqt2 + * ---------------------------------- + * 0 s-c c+s + * 1 -s-c -c+s + * 2 -s+c -c-s + * 3 s+c c-s + */ + long double s; + long double c; + __sincosl (x, &s, &c); + switch (n & 3) + { + case 0: + temp = c + s; + break; + case 1: + temp = -c + s; + break; + case 2: + temp = -c - s; + break; + case 3: + temp = c - s; + break; + } + b = invsqrtpi * temp / __ieee754_sqrtl (x); + } + else + { + a = __ieee754_j0l (x); + b = __ieee754_j1l (x); + for (i = 1; i < n; i++) + { + temp = b; + b = b * ((long double) (i + i) / x) - a; /* avoid underflow */ + a = temp; + } + } + } + else + { + if (ix < 0x3e100000) + { /* x < 2**-29 */ + /* x is tiny, return the first Taylor expansion of J(n,x) + * J(n,x) = 1/n!*(x/2)^n - ... + */ + if (n >= 33) /* underflow, result < 10^-300 */ + b = zero; + else + { + temp = x * 0.5; + b = temp; + for (a = one, i = 2; i <= n; i++) + { + a *= (long double) i; /* a = n! */ + b *= temp; /* b = (x/2)^n */ + } + b = b / a; + } + } + else + { + /* use backward recurrence */ + /* x x^2 x^2 + * J(n,x)/J(n-1,x) = ---- ------ ------ ..... + * 2n - 2(n+1) - 2(n+2) + * + * 1 1 1 + * (for large x) = ---- ------ ------ ..... + * 2n 2(n+1) 2(n+2) + * -- - ------ - ------ - + * x x x + * + * Let w = 2n/x and h=2/x, then the above quotient + * is equal to the continued fraction: + * 1 + * = ----------------------- + * 1 + * w - ----------------- + * 1 + * w+h - --------- + * w+2h - ... + * + * To determine how many terms needed, let + * Q(0) = w, Q(1) = w(w+h) - 1, + * Q(k) = (w+k*h)*Q(k-1) - Q(k-2), + * When Q(k) > 1e4 good for single + * When Q(k) > 1e9 good for double + * When Q(k) > 1e17 good for quadruple + */ + /* determine k */ + long double t, v; + long double q0, q1, h, tmp; + int32_t k, m; + w = (n + n) / (long double) x; + h = 2.0L / (long double) x; + q0 = w; + z = w + h; + q1 = w * z - 1.0L; + k = 1; + while (q1 < 1.0e17L) + { + k += 1; + z += h; + tmp = z * q1 - q0; + q0 = q1; + q1 = tmp; + } + m = n + n; + for (t = zero, i = 2 * (n + k); i >= m; i -= 2) + t = one / (i / x - t); + a = t; + b = one; + /* estimate log((2/x)^n*n!) = n*log(2/x)+n*ln(n) + * Hence, if n*(log(2n/x)) > ... + * single 8.8722839355e+01 + * double 7.09782712893383973096e+02 + * long double 1.1356523406294143949491931077970765006170e+04 + * then recurrent value may overflow and the result is + * likely underflow to zero + */ + tmp = n; + v = two / x; + tmp = tmp * __ieee754_logl (fabsl (v * tmp)); + + if (tmp < 1.1356523406294143949491931077970765006170e+04L) + { + for (i = n - 1, di = (long double) (i + i); i > 0; i--) + { + temp = b; + b *= di; + b = b / x - a; + a = temp; + di -= two; + } + } + else + { + for (i = n - 1, di = (long double) (i + i); i > 0; i--) + { + temp = b; + b *= di; + b = b / x - a; + a = temp; + di -= two; + /* scale b to avoid spurious overflow */ + if (b > 1e100L) + { + a /= b; + t /= b; + b = one; + } + } + } + b = (t * __ieee754_j0l (x) / b); + } + } + if (sgn == 1) + return -b; + else + return b; +} + +#ifdef __STDC__ +long double +__ieee754_ynl (int n, long double x) +#else +long double +__ieee754_ynl (n, x) + int n; + long double x; +#endif +{ + u_int32_t se; + int32_t i, ix; + int32_t sign; + long double a, b, temp; + ieee854_long_double_shape_type u; + + u.value = x; + se = u.parts32.w0; + ix = se & 0x7fffffff; + + /* if Y(n,NaN) is NaN */ + if (ix >= 0x7ff00000) + { + if ((u.parts32.w0 & 0xfffff) | u.parts32.w1 + | (u.parts32.w2 & 0x7fffffff) | u.parts32.w3) + return x + x; + } + if (x <= 0.0L) + { + if (x == 0.0L) + return -HUGE_VALL + x; + if (se & 0x80000000) + return zero / (zero * x); + } + sign = 1; + if (n < 0) + { + n = -n; + sign = 1 - ((n & 1) << 1); + } + if (n == 0) + return (__ieee754_y0l (x)); + if (n == 1) + return (sign * __ieee754_y1l (x)); + if (ix >= 0x7ff00000) + return zero; + if (ix >= 0x52D00000) + { /* x > 2**302 */ + + /* ??? See comment above on the possible futility of this. */ + + /* (x >> n**2) + * Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi) + * Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi) + * Let s=sin(x), c=cos(x), + * xn=x-(2n+1)*pi/4, sqt2 = sqrt(2),then + * + * n sin(xn)*sqt2 cos(xn)*sqt2 + * ---------------------------------- + * 0 s-c c+s + * 1 -s-c -c+s + * 2 -s+c -c-s + * 3 s+c c-s + */ + long double s; + long double c; + __sincosl (x, &s, &c); + switch (n & 3) + { + case 0: + temp = s - c; + break; + case 1: + temp = -s - c; + break; + case 2: + temp = -s + c; + break; + case 3: + temp = s + c; + break; + } + b = invsqrtpi * temp / __ieee754_sqrtl (x); + } + else + { + a = __ieee754_y0l (x); + b = __ieee754_y1l (x); + /* quit if b is -inf */ + u.value = b; + se = u.parts32.w0 & 0xfff00000; + for (i = 1; i < n && se != 0xfff00000; i++) + { + temp = b; + b = ((long double) (i + i) / x) * b - a; + u.value = b; + se = u.parts32.w0 & 0xfff00000; + a = temp; + } + } + if (sign > 0) + return b; + else + return -b; +} diff --git a/sysdeps/ieee754/ldbl-128ibm/e_lgammal_r.c b/sysdeps/ieee754/ldbl-128ibm/e_lgammal_r.c new file mode 100644 index 0000000..9bcaaf7 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/e_lgammal_r.c @@ -0,0 +1,3 @@ +/* Looks like we can use ieee854 e_lgammal_r.c as is for IBM extended format. */ +#include + diff --git a/sysdeps/ieee754/ldbl-128ibm/e_log10l.c b/sysdeps/ieee754/ldbl-128ibm/e_log10l.c new file mode 100644 index 0000000..27e2c71 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/e_log10l.c @@ -0,0 +1,258 @@ +/* log10l.c + * + * Common logarithm, 128-bit long double precision + * + * + * + * SYNOPSIS: + * + * long double x, y, log10l(); + * + * y = log10l( x ); + * + * + * + * DESCRIPTION: + * + * Returns the base 10 logarithm of x. + * + * The argument is separated into its exponent and fractional + * parts. If the exponent is between -1 and +1, the logarithm + * of the fraction is approximated by + * + * log(1+x) = x - 0.5 x^2 + x^3 P(x)/Q(x). + * + * Otherwise, setting z = 2(x-1)/x+1), + * + * log(x) = z + z^3 P(z)/Q(z). + * + * + * + * ACCURACY: + * + * Relative error: + * arithmetic domain # trials peak rms + * IEEE 0.5, 2.0 30000 2.3e-34 4.9e-35 + * IEEE exp(+-10000) 30000 1.0e-34 4.1e-35 + * + * In the tests over the interval exp(+-10000), the logarithms + * of the random arguments were uniformly distributed over + * [-10000, +10000]. + * + */ + +/* + Cephes Math Library Release 2.2: January, 1991 + Copyright 1984, 1991 by Stephen L. Moshier + Adapted for glibc November, 2001 + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + */ + +#include "math.h" +#include "math_private.h" + +/* Coefficients for ln(1+x) = x - x**2/2 + x**3 P(x)/Q(x) + * 1/sqrt(2) <= x < sqrt(2) + * Theoretical peak relative error = 5.3e-37, + * relative peak error spread = 2.3e-14 + */ +static const long double P[13] = +{ + 1.313572404063446165910279910527789794488E4L, + 7.771154681358524243729929227226708890930E4L, + 2.014652742082537582487669938141683759923E5L, + 3.007007295140399532324943111654767187848E5L, + 2.854829159639697837788887080758954924001E5L, + 1.797628303815655343403735250238293741397E5L, + 7.594356839258970405033155585486712125861E4L, + 2.128857716871515081352991964243375186031E4L, + 3.824952356185897735160588078446136783779E3L, + 4.114517881637811823002128927449878962058E2L, + 2.321125933898420063925789532045674660756E1L, + 4.998469661968096229986658302195402690910E-1L, + 1.538612243596254322971797716843006400388E-6L +}; +static const long double Q[12] = +{ + 3.940717212190338497730839731583397586124E4L, + 2.626900195321832660448791748036714883242E5L, + 7.777690340007566932935753241556479363645E5L, + 1.347518538384329112529391120390701166528E6L, + 1.514882452993549494932585972882995548426E6L, + 1.158019977462989115839826904108208787040E6L, + 6.132189329546557743179177159925690841200E5L, + 2.248234257620569139969141618556349415120E5L, + 5.605842085972455027590989944010492125825E4L, + 9.147150349299596453976674231612674085381E3L, + 9.104928120962988414618126155557301584078E2L, + 4.839208193348159620282142911143429644326E1L +/* 1.000000000000000000000000000000000000000E0L, */ +}; + +/* Coefficients for log(x) = z + z^3 P(z^2)/Q(z^2), + * where z = 2(x-1)/(x+1) + * 1/sqrt(2) <= x < sqrt(2) + * Theoretical peak relative error = 1.1e-35, + * relative peak error spread 1.1e-9 + */ +static const long double R[6] = +{ + 1.418134209872192732479751274970992665513E5L, + -8.977257995689735303686582344659576526998E4L, + 2.048819892795278657810231591630928516206E4L, + -2.024301798136027039250415126250455056397E3L, + 8.057002716646055371965756206836056074715E1L, + -8.828896441624934385266096344596648080902E-1L +}; +static const long double S[6] = +{ + 1.701761051846631278975701529965589676574E6L, + -1.332535117259762928288745111081235577029E6L, + 4.001557694070773974936904547424676279307E5L, + -5.748542087379434595104154610899551484314E4L, + 3.998526750980007367835804959888064681098E3L, + -1.186359407982897997337150403816839480438E2L +/* 1.000000000000000000000000000000000000000E0L, */ +}; + +static const long double +/* log10(2) */ +L102A = 0.3125L, +L102B = -1.14700043360188047862611052755069732318101185E-2L, +/* log10(e) */ +L10EA = 0.5L, +L10EB = -6.570551809674817234887108108339491770560299E-2L, +/* sqrt(2)/2 */ +SQRTH = 7.071067811865475244008443621048490392848359E-1L; + + + +/* Evaluate P[n] x^n + P[n-1] x^(n-1) + ... + P[0] */ + +static long double +neval (long double x, const long double *p, int n) +{ + long double y; + + p += n; + y = *p--; + do + { + y = y * x + *p--; + } + while (--n > 0); + return y; +} + + +/* Evaluate x^n+1 + P[n] x^(n) + P[n-1] x^(n-1) + ... + P[0] */ + +static long double +deval (long double x, const long double *p, int n) +{ + long double y; + + p += n; + y = x + *p--; + do + { + y = y * x + *p--; + } + while (--n > 0); + return y; +} + + + +long double +__ieee754_log10l (x) + long double x; +{ + long double z; + long double y; + int e; + int64_t hx, lx; + +/* Test for domain */ + GET_LDOUBLE_WORDS64 (hx, lx, x); + if (((hx & 0x7fffffffffffffffLL) | (lx & 0x7fffffffffffffffLL)) == 0) + return (-1.0L / (x - x)); + if (hx < 0) + return (x - x) / (x - x); + if (hx >= 0x7ff0000000000000LL) + return (x + x); + +/* separate mantissa from exponent */ + +/* Note, frexp is used so that denormal numbers + * will be handled properly. + */ + x = __frexpl (x, &e); + + +/* logarithm using log(x) = z + z**3 P(z)/Q(z), + * where z = 2(x-1)/x+1) + */ + if ((e > 2) || (e < -2)) + { + if (x < SQRTH) + { /* 2( 2x-1 )/( 2x+1 ) */ + e -= 1; + z = x - 0.5L; + y = 0.5L * z + 0.5L; + } + else + { /* 2 (x-1)/(x+1) */ + z = x - 0.5L; + z -= 0.5L; + y = 0.5L * x + 0.5L; + } + x = z / y; + z = x * x; + y = x * (z * neval (z, R, 5) / deval (z, S, 5)); + goto done; + } + + +/* logarithm using log(1+x) = x - .5x**2 + x**3 P(x)/Q(x) */ + + if (x < SQRTH) + { + e -= 1; + x = 2.0 * x - 1.0L; /* 2x - 1 */ + } + else + { + x = x - 1.0L; + } + z = x * x; + y = x * (z * neval (x, P, 12) / deval (x, Q, 11)); + y = y - 0.5 * z; + +done: + + /* Multiply log of fraction by log10(e) + * and base 2 exponent by log10(2). + */ + z = y * L10EB; + z += x * L10EB; + z += e * L102B; + z += y * L10EA; + z += x * L10EA; + z += e * L102A; + return (z); +} diff --git a/sysdeps/ieee754/ldbl-128ibm/e_log2l.c b/sysdeps/ieee754/ldbl-128ibm/e_log2l.c new file mode 100644 index 0000000..fe8a8e1 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/e_log2l.c @@ -0,0 +1,250 @@ +/* log2l.c + * Base 2 logarithm, 128-bit long double precision + * + * + * + * SYNOPSIS: + * + * long double x, y, log2l(); + * + * y = log2l( x ); + * + * + * + * DESCRIPTION: + * + * Returns the base 2 logarithm of x. + * + * The argument is separated into its exponent and fractional + * parts. If the exponent is between -1 and +1, the (natural) + * logarithm of the fraction is approximated by + * + * log(1+x) = x - 0.5 x^2 + x^3 P(x)/Q(x). + * + * Otherwise, setting z = 2(x-1)/x+1), + * + * log(x) = z + z^3 P(z)/Q(z). + * + * + * + * ACCURACY: + * + * Relative error: + * arithmetic domain # trials peak rms + * IEEE 0.5, 2.0 100,000 2.6e-34 4.9e-35 + * IEEE exp(+-10000) 100,000 9.6e-35 4.0e-35 + * + * In the tests over the interval exp(+-10000), the logarithms + * of the random arguments were uniformly distributed over + * [-10000, +10000]. + * + */ + +/* + Cephes Math Library Release 2.2: January, 1991 + Copyright 1984, 1991 by Stephen L. Moshier + Adapted for glibc November, 2001 + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "math.h" +#include "math_private.h" + +/* Coefficients for ln(1+x) = x - x**2/2 + x**3 P(x)/Q(x) + * 1/sqrt(2) <= x < sqrt(2) + * Theoretical peak relative error = 5.3e-37, + * relative peak error spread = 2.3e-14 + */ +static const long double P[13] = +{ + 1.313572404063446165910279910527789794488E4L, + 7.771154681358524243729929227226708890930E4L, + 2.014652742082537582487669938141683759923E5L, + 3.007007295140399532324943111654767187848E5L, + 2.854829159639697837788887080758954924001E5L, + 1.797628303815655343403735250238293741397E5L, + 7.594356839258970405033155585486712125861E4L, + 2.128857716871515081352991964243375186031E4L, + 3.824952356185897735160588078446136783779E3L, + 4.114517881637811823002128927449878962058E2L, + 2.321125933898420063925789532045674660756E1L, + 4.998469661968096229986658302195402690910E-1L, + 1.538612243596254322971797716843006400388E-6L +}; +static const long double Q[12] = +{ + 3.940717212190338497730839731583397586124E4L, + 2.626900195321832660448791748036714883242E5L, + 7.777690340007566932935753241556479363645E5L, + 1.347518538384329112529391120390701166528E6L, + 1.514882452993549494932585972882995548426E6L, + 1.158019977462989115839826904108208787040E6L, + 6.132189329546557743179177159925690841200E5L, + 2.248234257620569139969141618556349415120E5L, + 5.605842085972455027590989944010492125825E4L, + 9.147150349299596453976674231612674085381E3L, + 9.104928120962988414618126155557301584078E2L, + 4.839208193348159620282142911143429644326E1L +/* 1.000000000000000000000000000000000000000E0L, */ +}; + +/* Coefficients for log(x) = z + z^3 P(z^2)/Q(z^2), + * where z = 2(x-1)/(x+1) + * 1/sqrt(2) <= x < sqrt(2) + * Theoretical peak relative error = 1.1e-35, + * relative peak error spread 1.1e-9 + */ +static const long double R[6] = +{ + 1.418134209872192732479751274970992665513E5L, + -8.977257995689735303686582344659576526998E4L, + 2.048819892795278657810231591630928516206E4L, + -2.024301798136027039250415126250455056397E3L, + 8.057002716646055371965756206836056074715E1L, + -8.828896441624934385266096344596648080902E-1L +}; +static const long double S[6] = +{ + 1.701761051846631278975701529965589676574E6L, + -1.332535117259762928288745111081235577029E6L, + 4.001557694070773974936904547424676279307E5L, + -5.748542087379434595104154610899551484314E4L, + 3.998526750980007367835804959888064681098E3L, + -1.186359407982897997337150403816839480438E2L +/* 1.000000000000000000000000000000000000000E0L, */ +}; + +static const long double +/* log2(e) - 1 */ +LOG2EA = 4.4269504088896340735992468100189213742664595E-1L, +/* sqrt(2)/2 */ +SQRTH = 7.071067811865475244008443621048490392848359E-1L; + + +/* Evaluate P[n] x^n + P[n-1] x^(n-1) + ... + P[0] */ + +static long double +neval (long double x, const long double *p, int n) +{ + long double y; + + p += n; + y = *p--; + do + { + y = y * x + *p--; + } + while (--n > 0); + return y; +} + + +/* Evaluate x^n+1 + P[n] x^(n) + P[n-1] x^(n-1) + ... + P[0] */ + +static long double +deval (long double x, const long double *p, int n) +{ + long double y; + + p += n; + y = x + *p--; + do + { + y = y * x + *p--; + } + while (--n > 0); + return y; +} + + + +long double +__ieee754_log2l (x) + long double x; +{ + long double z; + long double y; + int e; + int64_t hx, lx; + +/* Test for domain */ + GET_LDOUBLE_WORDS64 (hx, lx, x); + if (((hx & 0x7fffffffffffffffLL) | (lx & 0x7fffffffffffffffLL)) == 0) + return (-1.0L / (x - x)); + if (hx < 0) + return (x - x) / (x - x); + if (hx >= 0x7ff0000000000000LL) + return (x + x); + +/* separate mantissa from exponent */ + +/* Note, frexp is used so that denormal numbers + * will be handled properly. + */ + x = __frexpl (x, &e); + + +/* logarithm using log(x) = z + z**3 P(z)/Q(z), + * where z = 2(x-1)/x+1) + */ + if ((e > 2) || (e < -2)) + { + if (x < SQRTH) + { /* 2( 2x-1 )/( 2x+1 ) */ + e -= 1; + z = x - 0.5L; + y = 0.5L * z + 0.5L; + } + else + { /* 2 (x-1)/(x+1) */ + z = x - 0.5L; + z -= 0.5L; + y = 0.5L * x + 0.5L; + } + x = z / y; + z = x * x; + y = x * (z * neval (z, R, 5) / deval (z, S, 5)); + goto done; + } + + +/* logarithm using log(1+x) = x - .5x**2 + x**3 P(x)/Q(x) */ + + if (x < SQRTH) + { + e -= 1; + x = 2.0 * x - 1.0L; /* 2x - 1 */ + } + else + { + x = x - 1.0L; + } + z = x * x; + y = x * (z * neval (x, P, 12) / deval (x, Q, 11)); + y = y - 0.5 * z; + +done: + +/* Multiply log of fraction by log2(e) + * and base 2 exponent by 1 + */ + z = y * LOG2EA; + z += x * LOG2EA; + z += y; + z += x; + z += e; + return (z); +} diff --git a/sysdeps/ieee754/ldbl-128ibm/e_logl.c b/sysdeps/ieee754/ldbl-128ibm/e_logl.c new file mode 100644 index 0000000..aa5fc37 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/e_logl.c @@ -0,0 +1,281 @@ +/* logll.c + * + * Natural logarithm for 128-bit long double precision. + * + * + * + * SYNOPSIS: + * + * long double x, y, logl(); + * + * y = logl( x ); + * + * + * + * DESCRIPTION: + * + * Returns the base e (2.718...) logarithm of x. + * + * The argument is separated into its exponent and fractional + * parts. Use of a lookup table increases the speed of the routine. + * The program uses logarithms tabulated at intervals of 1/128 to + * cover the domain from approximately 0.7 to 1.4. + * + * On the interval [-1/128, +1/128] the logarithm of 1+x is approximated by + * log(1+x) = x - 0.5 x^2 + x^3 P(x) . + * + * + * + * ACCURACY: + * + * Relative error: + * arithmetic domain # trials peak rms + * IEEE 0.875, 1.125 100000 1.2e-34 4.1e-35 + * IEEE 0.125, 8 100000 1.2e-34 4.1e-35 + * + * + * WARNING: + * + * This program uses integer operations on bit fields of floating-point + * numbers. It does not work with data structures other than the + * structure assumed. + * + */ + +/* Copyright 2001 by Stephen L. Moshier + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include "math_private.h" + +/* log(1+x) = x - .5 x^2 + x^3 l(x) + -.0078125 <= x <= +.0078125 + peak relative error 1.2e-37 */ +static const long double +l3 = 3.333333333333333333333333333333336096926E-1L, +l4 = -2.499999999999999999999999999486853077002E-1L, +l5 = 1.999999999999999999999999998515277861905E-1L, +l6 = -1.666666666666666666666798448356171665678E-1L, +l7 = 1.428571428571428571428808945895490721564E-1L, +l8 = -1.249999999999999987884655626377588149000E-1L, +l9 = 1.111111111111111093947834982832456459186E-1L, +l10 = -1.000000000000532974938900317952530453248E-1L, +l11 = 9.090909090915566247008015301349979892689E-2L, +l12 = -8.333333211818065121250921925397567745734E-2L, +l13 = 7.692307559897661630807048686258659316091E-2L, +l14 = -7.144242754190814657241902218399056829264E-2L, +l15 = 6.668057591071739754844678883223432347481E-2L; + +/* Lookup table of ln(t) - (t-1) + t = 0.5 + (k+26)/128) + k = 0, ..., 91 */ +static const long double logtbl[92] = { +-5.5345593589352099112142921677820359632418E-2L, +-5.2108257402767124761784665198737642086148E-2L, +-4.8991686870576856279407775480686721935120E-2L, +-4.5993270766361228596215288742353061431071E-2L, +-4.3110481649613269682442058976885699556950E-2L, +-4.0340872319076331310838085093194799765520E-2L, +-3.7682072451780927439219005993827431503510E-2L, +-3.5131785416234343803903228503274262719586E-2L, +-3.2687785249045246292687241862699949178831E-2L, +-3.0347913785027239068190798397055267411813E-2L, +-2.8110077931525797884641940838507561326298E-2L, +-2.5972247078357715036426583294246819637618E-2L, +-2.3932450635346084858612873953407168217307E-2L, +-2.1988775689981395152022535153795155900240E-2L, +-2.0139364778244501615441044267387667496733E-2L, +-1.8382413762093794819267536615342902718324E-2L, +-1.6716169807550022358923589720001638093023E-2L, +-1.5138929457710992616226033183958974965355E-2L, +-1.3649036795397472900424896523305726435029E-2L, +-1.2244881690473465543308397998034325468152E-2L, +-1.0924898127200937840689817557742469105693E-2L, +-9.6875626072830301572839422532631079809328E-3L, +-8.5313926245226231463436209313499745894157E-3L, +-7.4549452072765973384933565912143044991706E-3L, +-6.4568155251217050991200599386801665681310E-3L, +-5.5356355563671005131126851708522185605193E-3L, +-4.6900728132525199028885749289712348829878E-3L, +-3.9188291218610470766469347968659624282519E-3L, +-3.2206394539524058873423550293617843896540E-3L, +-2.5942708080877805657374888909297113032132E-3L, +-2.0385211375711716729239156839929281289086E-3L, +-1.5522183228760777967376942769773768850872E-3L, +-1.1342191863606077520036253234446621373191E-3L, +-7.8340854719967065861624024730268350459991E-4L, +-4.9869831458030115699628274852562992756174E-4L, +-2.7902661731604211834685052867305795169688E-4L, +-1.2335696813916860754951146082826952093496E-4L, +-3.0677461025892873184042490943581654591817E-5L, +#define ZERO logtbl[38] + 0.0000000000000000000000000000000000000000E0L, +-3.0359557945051052537099938863236321874198E-5L, +-1.2081346403474584914595395755316412213151E-4L, +-2.7044071846562177120083903771008342059094E-4L, +-4.7834133324631162897179240322783590830326E-4L, +-7.4363569786340080624467487620270965403695E-4L, +-1.0654639687057968333207323853366578860679E-3L, +-1.4429854811877171341298062134712230604279E-3L, +-1.8753781835651574193938679595797367137975E-3L, +-2.3618380914922506054347222273705859653658E-3L, +-2.9015787624124743013946600163375853631299E-3L, +-3.4938307889254087318399313316921940859043E-3L, +-4.1378413103128673800485306215154712148146E-3L, +-4.8328735414488877044289435125365629849599E-3L, +-5.5782063183564351739381962360253116934243E-3L, +-6.3731336597098858051938306767880719015261E-3L, +-7.2169643436165454612058905294782949315193E-3L, +-8.1090214990427641365934846191367315083867E-3L, +-9.0486422112807274112838713105168375482480E-3L, +-1.0035177140880864314674126398350812606841E-2L, +-1.1067990155502102718064936259435676477423E-2L, +-1.2146457974158024928196575103115488672416E-2L, +-1.3269969823361415906628825374158424754308E-2L, +-1.4437927104692837124388550722759686270765E-2L, +-1.5649743073340777659901053944852735064621E-2L, +-1.6904842527181702880599758489058031645317E-2L, +-1.8202661505988007336096407340750378994209E-2L, +-1.9542647000370545390701192438691126552961E-2L, +-2.0924256670080119637427928803038530924742E-2L, +-2.2346958571309108496179613803760727786257E-2L, +-2.3810230892650362330447187267648486279460E-2L, +-2.5313561699385640380910474255652501521033E-2L, +-2.6856448685790244233704909690165496625399E-2L, +-2.8438398935154170008519274953860128449036E-2L, +-3.0058928687233090922411781058956589863039E-2L, +-3.1717563112854831855692484086486099896614E-2L, +-3.3413836095418743219397234253475252001090E-2L, +-3.5147290019036555862676702093393332533702E-2L, +-3.6917475563073933027920505457688955423688E-2L, +-3.8723951502862058660874073462456610731178E-2L, +-4.0566284516358241168330505467000838017425E-2L, +-4.2444048996543693813649967076598766917965E-2L, +-4.4356826869355401653098777649745233339196E-2L, +-4.6304207416957323121106944474331029996141E-2L, +-4.8285787106164123613318093945035804818364E-2L, +-5.0301169421838218987124461766244507342648E-2L, +-5.2349964705088137924875459464622098310997E-2L, +-5.4431789996103111613753440311680967840214E-2L, +-5.6546268881465384189752786409400404404794E-2L, +-5.8693031345788023909329239565012647817664E-2L, +-6.0871713627532018185577188079210189048340E-2L, +-6.3081958078862169742820420185833800925568E-2L, +-6.5323413029406789694910800219643791556918E-2L, +-6.7595732653791419081537811574227049288168E-2L +}; + +/* ln(2) = ln2a + ln2b with extended precision. */ +static const long double + ln2a = 6.93145751953125e-1L, + ln2b = 1.4286068203094172321214581765680755001344E-6L; + +long double +__ieee754_logl(long double x) +{ + long double z, y, w; + ieee854_long_double_shape_type u, t; + unsigned int m; + int k, e; + + u.value = x; + m = u.parts32.w0; + + /* Check for IEEE special cases. */ + k = m & 0x7fffffff; + /* log(0) = -infinity. */ + if ((k | u.parts32.w1 | (u.parts32.w2 & 0x7fffffff) | u.parts32.w3) == 0) + { + return -0.5L / ZERO; + } + /* log ( x < 0 ) = NaN */ + if (m & 0x80000000) + { + return (x - x) / ZERO; + } + /* log (infinity or NaN) */ + if (k >= 0x7ff00000) + { + return x + x; + } + + /* On this interval the table is not used due to cancellation error. */ + if ((x <= 1.0078125L) && (x >= 0.9921875L)) + { + z = x - 1.0L; + k = 64; + t.value = 1.0L; + e = 0; + } + else + { + /* Extract exponent and reduce domain to 0.703125 <= u < 1.40625 */ + unsigned int w0; + e = (int) (m >> 20) - (int) 0x3fe; + m &= 0xfffff; + w0 = m | 0x3fe00000; + m |= 0x100000; + /* Find lookup table index k from high order bits of the significand. */ + if (m < 0x168000) + { + k = (m - 0xff000) >> 13; + /* t is the argument 0.5 + (k+26)/128 + of the nearest item to u in the lookup table. */ + t.parts32.w0 = 0x3ff00000 + (k << 13); + t.parts32.w1 = 0; + t.parts32.w2 = 0; + t.parts32.w3 = 0; + w0 += 0x100000; + e -= 1; + k += 64; + } + else + { + k = (m - 0xfe000) >> 14; + t.parts32.w0 = 0x3fe00000 + (k << 14); + t.parts32.w1 = 0; + t.parts32.w2 = 0; + t.parts32.w3 = 0; + } + u.value = __scalbnl (u.value, ((int) ((w0 - u.parts32.w0) * 2)) >> 21); + /* log(u) = log( t u/t ) = log(t) + log(u/t) + log(t) is tabulated in the lookup table. + Express log(u/t) = log(1+z), where z = u/t - 1 = (u-t)/t. + cf. Cody & Waite. */ + z = (u.value - t.value) / t.value; + } + /* Series expansion of log(1+z). */ + w = z * z; + y = ((((((((((((l15 * z + + l14) * z + + l13) * z + + l12) * z + + l11) * z + + l10) * z + + l9) * z + + l8) * z + + l7) * z + + l6) * z + + l5) * z + + l4) * z + + l3) * z * w; + y -= 0.5 * w; + y += e * ln2b; /* Base 2 exponent offset times ln(2). */ + y += z; + y += logtbl[k-26]; /* log(t) - (t-1) */ + y += (t.value - 1.0L); + y += e * ln2a; + return y; +} diff --git a/sysdeps/ieee754/ldbl-128ibm/e_powl.c b/sysdeps/ieee754/ldbl-128ibm/e_powl.c new file mode 100644 index 0000000..feeaa8c --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/e_powl.c @@ -0,0 +1,441 @@ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* Expansions and modifications for 128-bit long double are + Copyright (C) 2001 Stephen L. Moshier + and are incorporated herein by permission of the author. The author + reserves the right to distribute this material elsewhere under different + copying permissions. These modifications are distributed here under + the following terms: + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* __ieee754_powl(x,y) return x**y + * + * n + * Method: Let x = 2 * (1+f) + * 1. Compute and return log2(x) in two pieces: + * log2(x) = w1 + w2, + * where w1 has 113-53 = 60 bit trailing zeros. + * 2. Perform y*log2(x) = n+y' by simulating muti-precision + * arithmetic, where |y'|<=0.5. + * 3. Return x**y = 2**n*exp(y'*log2) + * + * Special cases: + * 1. (anything) ** 0 is 1 + * 2. (anything) ** 1 is itself + * 3. (anything) ** NAN is NAN + * 4. NAN ** (anything except 0) is NAN + * 5. +-(|x| > 1) ** +INF is +INF + * 6. +-(|x| > 1) ** -INF is +0 + * 7. +-(|x| < 1) ** +INF is +0 + * 8. +-(|x| < 1) ** -INF is +INF + * 9. +-1 ** +-INF is NAN + * 10. +0 ** (+anything except 0, NAN) is +0 + * 11. -0 ** (+anything except 0, NAN, odd integer) is +0 + * 12. +0 ** (-anything except 0, NAN) is +INF + * 13. -0 ** (-anything except 0, NAN, odd integer) is +INF + * 14. -0 ** (odd integer) = -( +0 ** (odd integer) ) + * 15. +INF ** (+anything except 0,NAN) is +INF + * 16. +INF ** (-anything except 0,NAN) is +0 + * 17. -INF ** (anything) = -0 ** (-anything) + * 18. (-anything) ** (integer) is (-1)**(integer)*(+anything**integer) + * 19. (-anything except 0 and inf) ** (non-integer) is NAN + * + */ + +#include "math.h" +#include "math_private.h" + +static const long double bp[] = { + 1.0L, + 1.5L, +}; + +/* log_2(1.5) */ +static const long double dp_h[] = { + 0.0, + 5.8496250072115607565592654282227158546448E-1L +}; + +/* Low part of log_2(1.5) */ +static const long double dp_l[] = { + 0.0, + 1.0579781240112554492329533686862998106046E-16L +}; + +static const long double zero = 0.0L, + one = 1.0L, + two = 2.0L, + two113 = 1.0384593717069655257060992658440192E34L, + huge = 1.0e3000L, + tiny = 1.0e-3000L; + +/* 3/2 log x = 3 z + z^3 + z^3 (z^2 R(z^2)) + z = (x-1)/(x+1) + 1 <= x <= 1.25 + Peak relative error 2.3e-37 */ +static const long double LN[] = +{ + -3.0779177200290054398792536829702930623200E1L, + 6.5135778082209159921251824580292116201640E1L, + -4.6312921812152436921591152809994014413540E1L, + 1.2510208195629420304615674658258363295208E1L, + -9.9266909031921425609179910128531667336670E-1L +}; +static const long double LD[] = +{ + -5.129862866715009066465422805058933131960E1L, + 1.452015077564081884387441590064272782044E2L, + -1.524043275549860505277434040464085593165E2L, + 7.236063513651544224319663428634139768808E1L, + -1.494198912340228235853027849917095580053E1L + /* 1.0E0 */ +}; + +/* exp(x) = 1 + x - x / (1 - 2 / (x - x^2 R(x^2))) + 0 <= x <= 0.5 + Peak relative error 5.7e-38 */ +static const long double PN[] = +{ + 5.081801691915377692446852383385968225675E8L, + 9.360895299872484512023336636427675327355E6L, + 4.213701282274196030811629773097579432957E4L, + 5.201006511142748908655720086041570288182E1L, + 9.088368420359444263703202925095675982530E-3L, +}; +static const long double PD[] = +{ + 3.049081015149226615468111430031590411682E9L, + 1.069833887183886839966085436512368982758E8L, + 8.259257717868875207333991924545445705394E5L, + 1.872583833284143212651746812884298360922E3L, + /* 1.0E0 */ +}; + +static const long double + /* ln 2 */ + lg2 = 6.9314718055994530941723212145817656807550E-1L, + lg2_h = 6.9314718055994528622676398299518041312695E-1L, + lg2_l = 2.3190468138462996154948554638754786504121E-17L, + ovt = 8.0085662595372944372e-0017L, + /* 2/(3*log(2)) */ + cp = 9.6179669392597560490661645400126142495110E-1L, + cp_h = 9.6179669392597555432899980587535537779331E-1L, + cp_l = 5.0577616648125906047157785230014751039424E-17L; + +#ifdef __STDC__ +long double +__ieee754_powl (long double x, long double y) +#else +long double +__ieee754_powl (x, y) + long double x, y; +#endif +{ + long double z, ax, z_h, z_l, p_h, p_l; + long double y1, t1, t2, r, s, t, u, v, w; + long double s2, s_h, s_l, t_h, t_l; + int32_t i, j, k, yisint, n; + u_int32_t ix, iy; + int32_t hx, hy; + ieee854_long_double_shape_type o, p, q; + + p.value = x; + hx = p.parts32.w0; + ix = hx & 0x7fffffff; + + q.value = y; + hy = q.parts32.w0; + iy = hy & 0x7fffffff; + + + /* y==zero: x**0 = 1 */ + if ((iy | q.parts32.w1 | (q.parts32.w2 & 0x7fffffff) | q.parts32.w3) == 0) + return one; + + /* 1.0**y = 1; -1.0**+-Inf = 1 */ + if (x == one) + return one; + if (x == -1.0L && iy == 0x7ff00000 + && (q.parts32.w1 | (q.parts32.w2 & 0x7fffffff) | q.parts32.w3) == 0) + return one; + + /* +-NaN return x+y */ + if ((ix > 0x7ff00000) + || ((ix == 0x7ff00000) + && ((p.parts32.w1 | (p.parts32.w2 & 0x7fffffff) | p.parts32.w3) != 0)) + || (iy > 0x7ff00000) + || ((iy == 0x7ff00000) + && ((q.parts32.w1 | (q.parts32.w2 & 0x7fffffff) | q.parts32.w3) != 0))) + return x + y; + + /* determine if y is an odd int when x < 0 + * yisint = 0 ... y is not an integer + * yisint = 1 ... y is an odd int + * yisint = 2 ... y is an even int + */ + yisint = 0; + if (hx < 0) + { + if ((q.parts32.w2 & 0x7fffffff) >= 0x43400000) /* Low part >= 2^53 */ + yisint = 2; /* even integer y */ + else if (iy >= 0x3ff00000) /* 1.0 */ + { + if (__floorl (y) == y) + { + z = 0.5 * y; + if (__floorl (z) == z) + yisint = 2; + else + yisint = 1; + } + } + } + + /* special value of y */ + if ((q.parts32.w1 | (q.parts32.w2 & 0x7fffffff) | q.parts32.w3) == 0) + { + if (iy == 0x7ff00000 && q.parts32.w1 == 0) /* y is +-inf */ + { + if (((ix - 0x3ff00000) | p.parts32.w1 + | (p.parts32.w2 & 0x7fffffff) | p.parts32.w3) == 0) + return y - y; /* inf**+-1 is NaN */ + else if (ix > 0x3ff00000 || fabsl (x) > 1.0L) + /* (|x|>1)**+-inf = inf,0 */ + return (hy >= 0) ? y : zero; + else + /* (|x|<1)**-,+inf = inf,0 */ + return (hy < 0) ? -y : zero; + } + if (iy == 0x3ff00000) + { /* y is +-1 */ + if (hy < 0) + return one / x; + else + return x; + } + if (hy == 0x40000000) + return x * x; /* y is 2 */ + if (hy == 0x3fe00000) + { /* y is 0.5 */ + if (hx >= 0) /* x >= +0 */ + return __ieee754_sqrtl (x); + } + } + + ax = fabsl (x); + /* special value of x */ + if ((p.parts32.w1 | (p.parts32.w2 & 0x7fffffff) | p.parts32.w3) == 0) + { + if (ix == 0x7ff00000 || ix == 0 || ix == 0x3ff00000) + { + z = ax; /*x is +-0,+-inf,+-1 */ + if (hy < 0) + z = one / z; /* z = (1/|x|) */ + if (hx < 0) + { + if (((ix - 0x3ff00000) | yisint) == 0) + { + z = (z - z) / (z - z); /* (-1)**non-int is NaN */ + } + else if (yisint == 1) + z = -z; /* (x<0)**odd = -(|x|**odd) */ + } + return z; + } + } + + /* (x<0)**(non-int) is NaN */ + if (((((u_int32_t) hx >> 31) - 1) | yisint) == 0) + return (x - x) / (x - x); + + /* |y| is huge. + 2^-16495 = 1/2 of smallest representable value. + If (1 - 1/131072)^y underflows, y > 1.4986e9 */ + if (iy > 0x41d654b0) + { + /* if (1 - 2^-113)^y underflows, y > 1.1873e38 */ + if (iy > 0x47d654b0) + { + if (ix <= 0x3fefffff) + return (hy < 0) ? huge * huge : tiny * tiny; + if (ix >= 0x3ff00000) + return (hy > 0) ? huge * huge : tiny * tiny; + } + /* over/underflow if x is not close to one */ + if (ix < 0x3fefffff) + return (hy < 0) ? huge * huge : tiny * tiny; + if (ix > 0x3ff00000) + return (hy > 0) ? huge * huge : tiny * tiny; + } + + n = 0; + /* take care subnormal number */ + if (ix < 0x00100000) + { + ax *= two113; + n -= 113; + o.value = ax; + ix = o.parts32.w0; + } + n += ((ix) >> 20) - 0x3ff; + j = ix & 0x000fffff; + /* determine interval */ + ix = j | 0x3ff00000; /* normalize ix */ + if (j <= 0x39880) + k = 0; /* |x|> 21); + ax = o.value; + + /* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */ + u = ax - bp[k]; /* bp[0]=1.0, bp[1]=1.5 */ + v = one / (ax + bp[k]); + s = u * v; + s_h = s; + + o.value = s_h; + o.parts32.w3 = 0; + o.parts32.w2 &= 0xffff8000; + s_h = o.value; + /* t_h=ax+bp[k] High */ + t_h = ax + bp[k]; + o.value = t_h; + o.parts32.w3 = 0; + o.parts32.w2 &= 0xffff8000; + t_h = o.value; + t_l = ax - (t_h - bp[k]); + s_l = v * ((u - s_h * t_h) - s_h * t_l); + /* compute log(ax) */ + s2 = s * s; + u = LN[0] + s2 * (LN[1] + s2 * (LN[2] + s2 * (LN[3] + s2 * LN[4]))); + v = LD[0] + s2 * (LD[1] + s2 * (LD[2] + s2 * (LD[3] + s2 * (LD[4] + s2)))); + r = s2 * s2 * u / v; + r += s_l * (s_h + s); + s2 = s_h * s_h; + t_h = 3.0 + s2 + r; + o.value = t_h; + o.parts32.w3 = 0; + o.parts32.w2 &= 0xffff8000; + t_h = o.value; + t_l = r - ((t_h - 3.0) - s2); + /* u+v = s*(1+...) */ + u = s_h * t_h; + v = s_l * t_h + t_l * s; + /* 2/(3log2)*(s+...) */ + p_h = u + v; + o.value = p_h; + o.parts32.w3 = 0; + o.parts32.w2 &= 0xffff8000; + p_h = o.value; + p_l = v - (p_h - u); + z_h = cp_h * p_h; /* cp_h+cp_l = 2/(3*log2) */ + z_l = cp_l * p_h + p_l * cp + dp_l[k]; + /* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */ + t = (long double) n; + t1 = (((z_h + z_l) + dp_h[k]) + t); + o.value = t1; + o.parts32.w3 = 0; + o.parts32.w2 &= 0xffff8000; + t1 = o.value; + t2 = z_l - (((t1 - t) - dp_h[k]) - z_h); + + /* s (sign of result -ve**odd) = -1 else = 1 */ + s = one; + if (((((u_int32_t) hx >> 31) - 1) | (yisint - 1)) == 0) + s = -one; /* (-ve)**(odd int) */ + + /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */ + y1 = y; + o.value = y1; + o.parts32.w3 = 0; + o.parts32.w2 &= 0xffff8000; + y1 = o.value; + p_l = (y - y1) * t1 + y * t2; + p_h = y1 * t1; + z = p_l + p_h; + o.value = z; + j = o.parts32.w0; + if (j >= 0x40d00000) /* z >= 16384 */ + { + /* if z > 16384 */ + if (((j - 0x40d00000) | o.parts32.w1 + | (o.parts32.w2 & 0x7fffffff) | o.parts32.w3) != 0) + return s * huge * huge; /* overflow */ + else + { + if (p_l + ovt > z - p_h) + return s * huge * huge; /* overflow */ + } + } + else if ((j & 0x7fffffff) >= 0x40d01b90) /* z <= -16495 */ + { + /* z < -16495 */ + if (((j - 0xc0d01bc0) | o.parts32.w1 + | (o.parts32.w2 & 0x7fffffff) | o.parts32.w3) != 0) + return s * tiny * tiny; /* underflow */ + else + { + if (p_l <= z - p_h) + return s * tiny * tiny; /* underflow */ + } + } + /* compute 2**(p_h+p_l) */ + i = j & 0x7fffffff; + k = (i >> 20) - 0x3ff; + n = 0; + if (i > 0x3fe00000) + { /* if |z| > 0.5, set n = [z+0.5] */ + n = __floorl (z + 0.5L); + t = n; + p_h -= t; + } + t = p_l + p_h; + o.value = t; + o.parts32.w3 = 0; + o.parts32.w2 &= 0xffff8000; + t = o.value; + u = t * lg2_h; + v = (p_l - (t - p_h)) * lg2 + t * lg2_l; + z = u + v; + w = v - (z - u); + /* exp(z) */ + t = z * z; + u = PN[0] + t * (PN[1] + t * (PN[2] + t * (PN[3] + t * PN[4]))); + v = PD[0] + t * (PD[1] + t * (PD[2] + t * (PD[3] + t))); + t1 = z - t * u / v; + r = (z * t1) / (t1 - two) - (w + z * w); + z = one - (r - z); + z = __scalbnl (z, n); + return s * z; +} diff --git a/sysdeps/ieee754/ldbl-128ibm/e_rem_pio2l.c b/sysdeps/ieee754/ldbl-128ibm/e_rem_pio2l.c new file mode 100644 index 0000000..416547c --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/e_rem_pio2l.c @@ -0,0 +1,277 @@ +/* Quad-precision floating point argument reduction. + Copyright (C) 1999,2004,2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include "math.h" +#include "math_private.h" +#include + +/* + * Table of constants for 2/pi, 5628 hexadecimal digits of 2/pi + */ +static const int32_t two_over_pi[] = { +0xa2f983, 0x6e4e44, 0x1529fc, 0x2757d1, 0xf534dd, 0xc0db62, +0x95993c, 0x439041, 0xfe5163, 0xabdebb, 0xc561b7, 0x246e3a, +0x424dd2, 0xe00649, 0x2eea09, 0xd1921c, 0xfe1deb, 0x1cb129, +0xa73ee8, 0x8235f5, 0x2ebb44, 0x84e99c, 0x7026b4, 0x5f7e41, +0x3991d6, 0x398353, 0x39f49c, 0x845f8b, 0xbdf928, 0x3b1ff8, +0x97ffde, 0x05980f, 0xef2f11, 0x8b5a0a, 0x6d1f6d, 0x367ecf, +0x27cb09, 0xb74f46, 0x3f669e, 0x5fea2d, 0x7527ba, 0xc7ebe5, +0xf17b3d, 0x0739f7, 0x8a5292, 0xea6bfb, 0x5fb11f, 0x8d5d08, +0x560330, 0x46fc7b, 0x6babf0, 0xcfbc20, 0x9af436, 0x1da9e3, +0x91615e, 0xe61b08, 0x659985, 0x5f14a0, 0x68408d, 0xffd880, +0x4d7327, 0x310606, 0x1556ca, 0x73a8c9, 0x60e27b, 0xc08c6b, +0x47c419, 0xc367cd, 0xdce809, 0x2a8359, 0xc4768b, 0x961ca6, +0xddaf44, 0xd15719, 0x053ea5, 0xff0705, 0x3f7e33, 0xe832c2, +0xde4f98, 0x327dbb, 0xc33d26, 0xef6b1e, 0x5ef89f, 0x3a1f35, +0xcaf27f, 0x1d87f1, 0x21907c, 0x7c246a, 0xfa6ed5, 0x772d30, +0x433b15, 0xc614b5, 0x9d19c3, 0xc2c4ad, 0x414d2c, 0x5d000c, +0x467d86, 0x2d71e3, 0x9ac69b, 0x006233, 0x7cd2b4, 0x97a7b4, +0xd55537, 0xf63ed7, 0x1810a3, 0xfc764d, 0x2a9d64, 0xabd770, +0xf87c63, 0x57b07a, 0xe71517, 0x5649c0, 0xd9d63b, 0x3884a7, +0xcb2324, 0x778ad6, 0x23545a, 0xb91f00, 0x1b0af1, 0xdfce19, +0xff319f, 0x6a1e66, 0x615799, 0x47fbac, 0xd87f7e, 0xb76522, +0x89e832, 0x60bfe6, 0xcdc4ef, 0x09366c, 0xd43f5d, 0xd7de16, +0xde3b58, 0x929bde, 0x2822d2, 0xe88628, 0x4d58e2, 0x32cac6, +0x16e308, 0xcb7de0, 0x50c017, 0xa71df3, 0x5be018, 0x34132e, +0x621283, 0x014883, 0x5b8ef5, 0x7fb0ad, 0xf2e91e, 0x434a48, +0xd36710, 0xd8ddaa, 0x425fae, 0xce616a, 0xa4280a, 0xb499d3, +0xf2a606, 0x7f775c, 0x83c2a3, 0x883c61, 0x78738a, 0x5a8caf, +0xbdd76f, 0x63a62d, 0xcbbff4, 0xef818d, 0x67c126, 0x45ca55, +0x36d9ca, 0xd2a828, 0x8d61c2, 0x77c912, 0x142604, 0x9b4612, +0xc459c4, 0x44c5c8, 0x91b24d, 0xf31700, 0xad43d4, 0xe54929, +0x10d5fd, 0xfcbe00, 0xcc941e, 0xeece70, 0xf53e13, 0x80f1ec, +0xc3e7b3, 0x28f8c7, 0x940593, 0x3e71c1, 0xb3092e, 0xf3450b, +0x9c1288, 0x7b20ab, 0x9fb52e, 0xc29247, 0x2f327b, 0x6d550c, +0x90a772, 0x1fe76b, 0x96cb31, 0x4a1679, 0xe27941, 0x89dff4, +0x9794e8, 0x84e6e2, 0x973199, 0x6bed88, 0x365f5f, 0x0efdbb, +0xb49a48, 0x6ca467, 0x427271, 0x325d8d, 0xb8159f, 0x09e5bc, +0x25318d, 0x3974f7, 0x1c0530, 0x010c0d, 0x68084b, 0x58ee2c, +0x90aa47, 0x02e774, 0x24d6bd, 0xa67df7, 0x72486e, 0xef169f, +0xa6948e, 0xf691b4, 0x5153d1, 0xf20acf, 0x339820, 0x7e4bf5, +0x6863b2, 0x5f3edd, 0x035d40, 0x7f8985, 0x295255, 0xc06437, +0x10d86d, 0x324832, 0x754c5b, 0xd4714e, 0x6e5445, 0xc1090b, +0x69f52a, 0xd56614, 0x9d0727, 0x50045d, 0xdb3bb4, 0xc576ea, +0x17f987, 0x7d6b49, 0xba271d, 0x296996, 0xacccc6, 0x5414ad, +0x6ae290, 0x89d988, 0x50722c, 0xbea404, 0x940777, 0x7030f3, +0x27fc00, 0xa871ea, 0x49c266, 0x3de064, 0x83dd97, 0x973fa3, +0xfd9443, 0x8c860d, 0xde4131, 0x9d3992, 0x8c70dd, 0xe7b717, +0x3bdf08, 0x2b3715, 0xa0805c, 0x93805a, 0x921110, 0xd8e80f, +0xaf806c, 0x4bffdb, 0x0f9038, 0x761859, 0x15a562, 0xbbcb61, +0xb989c7, 0xbd4010, 0x04f2d2, 0x277549, 0xf6b6eb, 0xbb22db, +0xaa140a, 0x2f2689, 0x768364, 0x333b09, 0x1a940e, 0xaa3a51, +0xc2a31d, 0xaeedaf, 0x12265c, 0x4dc26d, 0x9c7a2d, 0x9756c0, +0x833f03, 0xf6f009, 0x8c402b, 0x99316d, 0x07b439, 0x15200c, +0x5bc3d8, 0xc492f5, 0x4badc6, 0xa5ca4e, 0xcd37a7, 0x36a9e6, +0x9492ab, 0x6842dd, 0xde6319, 0xef8c76, 0x528b68, 0x37dbfc, +0xaba1ae, 0x3115df, 0xa1ae00, 0xdafb0c, 0x664d64, 0xb705ed, +0x306529, 0xbf5657, 0x3aff47, 0xb9f96a, 0xf3be75, 0xdf9328, +0x3080ab, 0xf68c66, 0x15cb04, 0x0622fa, 0x1de4d9, 0xa4b33d, +0x8f1b57, 0x09cd36, 0xe9424e, 0xa4be13, 0xb52333, 0x1aaaf0, +0xa8654f, 0xa5c1d2, 0x0f3f0b, 0xcd785b, 0x76f923, 0x048b7b, +0x721789, 0x53a6c6, 0xe26e6f, 0x00ebef, 0x584a9b, 0xb7dac4, +0xba66aa, 0xcfcf76, 0x1d02d1, 0x2df1b1, 0xc1998c, 0x77adc3, +0xda4886, 0xa05df7, 0xf480c6, 0x2ff0ac, 0x9aecdd, 0xbc5c3f, +0x6dded0, 0x1fc790, 0xb6db2a, 0x3a25a3, 0x9aaf00, 0x9353ad, +0x0457b6, 0xb42d29, 0x7e804b, 0xa707da, 0x0eaa76, 0xa1597b, +0x2a1216, 0x2db7dc, 0xfde5fa, 0xfedb89, 0xfdbe89, 0x6c76e4, +0xfca906, 0x70803e, 0x156e85, 0xff87fd, 0x073e28, 0x336761, +0x86182a, 0xeabd4d, 0xafe7b3, 0x6e6d8f, 0x396795, 0x5bbf31, +0x48d784, 0x16df30, 0x432dc7, 0x356125, 0xce70c9, 0xb8cb30, +0xfd6cbf, 0xa200a4, 0xe46c05, 0xa0dd5a, 0x476f21, 0xd21262, +0x845cb9, 0x496170, 0xe0566b, 0x015299, 0x375550, 0xb7d51e, +0xc4f133, 0x5f6e13, 0xe4305d, 0xa92e85, 0xc3b21d, 0x3632a1, +0xa4b708, 0xd4b1ea, 0x21f716, 0xe4698f, 0x77ff27, 0x80030c, +0x2d408d, 0xa0cd4f, 0x99a520, 0xd3a2b3, 0x0a5d2f, 0x42f9b4, +0xcbda11, 0xd0be7d, 0xc1db9b, 0xbd17ab, 0x81a2ca, 0x5c6a08, +0x17552e, 0x550027, 0xf0147f, 0x8607e1, 0x640b14, 0x8d4196, +0xdebe87, 0x2afdda, 0xb6256b, 0x34897b, 0xfef305, 0x9ebfb9, +0x4f6a68, 0xa82a4a, 0x5ac44f, 0xbcf82d, 0x985ad7, 0x95c7f4, +0x8d4d0d, 0xa63a20, 0x5f57a4, 0xb13f14, 0x953880, 0x0120cc, +0x86dd71, 0xb6dec9, 0xf560bf, 0x11654d, 0x6b0701, 0xacb08c, +0xd0c0b2, 0x485551, 0x0efb1e, 0xc37295, 0x3b06a3, 0x3540c0, +0x7bdc06, 0xcc45e0, 0xfa294e, 0xc8cad6, 0x41f3e8, 0xde647c, +0xd8649b, 0x31bed9, 0xc397a4, 0xd45877, 0xc5e369, 0x13daf0, +0x3c3aba, 0x461846, 0x5f7555, 0xf5bdd2, 0xc6926e, 0x5d2eac, +0xed440e, 0x423e1c, 0x87c461, 0xe9fd29, 0xf3d6e7, 0xca7c22, +0x35916f, 0xc5e008, 0x8dd7ff, 0xe26a6e, 0xc6fdb0, 0xc10893, +0x745d7c, 0xb2ad6b, 0x9d6ecd, 0x7b723e, 0x6a11c6, 0xa9cff7, +0xdf7329, 0xbac9b5, 0x5100b7, 0x0db2e2, 0x24ba74, 0x607de5, +0x8ad874, 0x2c150d, 0x0c1881, 0x94667e, 0x162901, 0x767a9f, +0xbefdfd, 0xef4556, 0x367ed9, 0x13d9ec, 0xb9ba8b, 0xfc97c4, +0x27a831, 0xc36ef1, 0x36c594, 0x56a8d8, 0xb5a8b4, 0x0ecccf, +0x2d8912, 0x34576f, 0x89562c, 0xe3ce99, 0xb920d6, 0xaa5e6b, +0x9c2a3e, 0xcc5f11, 0x4a0bfd, 0xfbf4e1, 0x6d3b8e, 0x2c86e2, +0x84d4e9, 0xa9b4fc, 0xd1eeef, 0xc9352e, 0x61392f, 0x442138, +0xc8d91b, 0x0afc81, 0x6a4afb, 0xd81c2f, 0x84b453, 0x8c994e, +0xcc2254, 0xdc552a, 0xd6c6c0, 0x96190b, 0xb8701a, 0x649569, +0x605a26, 0xee523f, 0x0f117f, 0x11b5f4, 0xf5cbfc, 0x2dbc34, +0xeebc34, 0xcc5de8, 0x605edd, 0x9b8e67, 0xef3392, 0xb817c9, +0x9b5861, 0xbc57e1, 0xc68351, 0x103ed8, 0x4871dd, 0xdd1c2d, +0xa118af, 0x462c21, 0xd7f359, 0x987ad9, 0xc0549e, 0xfa864f, +0xfc0656, 0xae79e5, 0x362289, 0x22ad38, 0xdc9367, 0xaae855, +0x382682, 0x9be7ca, 0xa40d51, 0xb13399, 0x0ed7a9, 0x480569, +0xf0b265, 0xa7887f, 0x974c88, 0x36d1f9, 0xb39221, 0x4a827b, +0x21cf98, 0xdc9f40, 0x5547dc, 0x3a74e1, 0x42eb67, 0xdf9dfe, +0x5fd45e, 0xa4677b, 0x7aacba, 0xa2f655, 0x23882b, 0x55ba41, +0x086e59, 0x862a21, 0x834739, 0xe6e389, 0xd49ee5, 0x40fb49, +0xe956ff, 0xca0f1c, 0x8a59c5, 0x2bfa94, 0xc5c1d3, 0xcfc50f, +0xae5adb, 0x86c547, 0x624385, 0x3b8621, 0x94792c, 0x876110, +0x7b4c2a, 0x1a2c80, 0x12bf43, 0x902688, 0x893c78, 0xe4c4a8, +0x7bdbe5, 0xc23ac4, 0xeaf426, 0x8a67f7, 0xbf920d, 0x2ba365, +0xb1933d, 0x0b7cbd, 0xdc51a4, 0x63dd27, 0xdde169, 0x19949a, +0x9529a8, 0x28ce68, 0xb4ed09, 0x209f44, 0xca984e, 0x638270, +0x237c7e, 0x32b90f, 0x8ef5a7, 0xe75614, 0x08f121, 0x2a9db5, +0x4d7e6f, 0x5119a5, 0xabf9b5, 0xd6df82, 0x61dd96, 0x023616, +0x9f3ac4, 0xa1a283, 0x6ded72, 0x7a8d39, 0xa9b882, 0x5c326b, +0x5b2746, 0xed3400, 0x7700d2, 0x55f4fc, 0x4d5901, 0x8071e0, +0xe13f89, 0xb295f3, 0x64a8f1, 0xaea74b, 0x38fc4c, 0xeab2bb, +0x47270b, 0xabc3a7, 0x34ba60, 0x52dd34, 0xf8563a, 0xeb7e8a, +0x31bb36, 0x5895b7, 0x47f7a9, 0x94c3aa, 0xd39225, 0x1e7f3e, +0xd8974e, 0xbba94f, 0xd8ae01, 0xe661b4, 0x393d8e, 0xa523aa, +0x33068e, 0x1633b5, 0x3bb188, 0x1d3a9d, 0x4013d0, 0xcc1be5, +0xf862e7, 0x3bf28f, 0x39b5bf, 0x0bc235, 0x22747e, 0xa247c0, +0xd52d1f, 0x19add3, 0x9094df, 0x9311d0, 0xb42b25, 0x496db2, +0xe264b2, 0x5ef135, 0x3bc6a4, 0x1a4ad0, 0xaac92e, 0x64e886, +0x573091, 0x982cfb, 0x311b1a, 0x08728b, 0xbdcee1, 0x60e142, +0xeb641d, 0xd0bba3, 0xe559d4, 0x597b8c, 0x2a4483, 0xf332ba, +0xf84867, 0x2c8d1b, 0x2fa9b0, 0x50f3dd, 0xf9f573, 0xdb61b4, +0xfe233e, 0x6c41a6, 0xeea318, 0x775a26, 0xbc5e5c, 0xcea708, +0x94dc57, 0xe20196, 0xf1e839, 0xbe4851, 0x5d2d2f, 0x4e9555, +0xd96ec2, 0xe7d755, 0x6304e0, 0xc02e0e, 0xfc40a0, 0xbbf9b3, +0x7125a7, 0x222dfb, 0xf619d8, 0x838c1c, 0x6619e6, 0xb20d55, +0xbb5137, 0x79e809, 0xaf9149, 0x0d73de, 0x0b0da5, 0xce7f58, +0xac1934, 0x724667, 0x7a1a13, 0x9e26bc, 0x4555e7, 0x585cb5, +0x711d14, 0x486991, 0x480d60, 0x56adab, 0xd62f64, 0x96ee0c, +0x212ff3, 0x5d6d88, 0xa67684, 0x95651e, 0xab9e0a, 0x4ddefe, +0x571010, 0x836a39, 0xf8ea31, 0x9e381d, 0xeac8b1, 0xcac96b, +0x37f21e, 0xd505e9, 0x984743, 0x9fc56c, 0x0331b7, 0x3b8bf8, +0x86e56a, 0x8dc343, 0x6230e7, 0x93cfd5, 0x6a8f2d, 0x733005, +0x1af021, 0xa09fcb, 0x7415a1, 0xd56b23, 0x6ff725, 0x2f4bc7, +0xb8a591, 0x7fac59, 0x5c55de, 0x212c38, 0xb13296, 0x5cff50, +0x366262, 0xfa7b16, 0xf4d9a6, 0x2acfe7, 0xf07403, 0xd4d604, +0x6fd916, 0x31b1bf, 0xcbb450, 0x5bd7c8, 0x0ce194, 0x6bd643, +0x4fd91c, 0xdf4543, 0x5f3453, 0xe2b5aa, 0xc9aec8, 0x131485, +0xf9d2bf, 0xbadb9e, 0x76f5b9, 0xaf15cf, 0xca3182, 0x14b56d, +0xe9fe4d, 0x50fc35, 0xf5aed5, 0xa2d0c1, 0xc96057, 0x192eb6, +0xe91d92, 0x07d144, 0xaea3c6, 0x343566, 0x26d5b4, 0x3161e2, +0x37f1a2, 0x209eff, 0x958e23, 0x493798, 0x35f4a6, 0x4bdc02, +0xc2be13, 0xbe80a0, 0x0b72a3, 0x115c5f, 0x1e1bd1, 0x0db4d3, +0x869e85, 0x96976b, 0x2ac91f, 0x8a26c2, 0x3070f0, 0x041412, +0xfc9fa5, 0xf72a38, 0x9c6878, 0xe2aa76, 0x50cfe1, 0x559274, +0x934e38, 0x0a92f7, 0x5533f0, 0xa63db4, 0x399971, 0xe2b755, +0xa98a7c, 0x008f19, 0xac54d2, 0x2ea0b4, 0xf5f3e0, 0x60c849, +0xffd269, 0xae52ce, 0x7a5fdd, 0xe9ce06, 0xfb0ae8, 0xa50cce, +0xea9d3e, 0x3766dd, 0xb834f5, 0x0da090, 0x846f88, 0x4ae3d5, +0x099a03, 0x2eae2d, 0xfcb40a, 0xfb9b33, 0xe281dd, 0x1b16ba, +0xd8c0af, 0xd96b97, 0xb52dc9, 0x9c277f, 0x5951d5, 0x21ccd6, +0xb6496b, 0x584562, 0xb3baf2, 0xa1a5c4, 0x7ca2cf, 0xa9b93d, +0x7b7b89, 0x483d38, +}; + +static const long double c[] = { +/* 93 bits of pi/2 */ +#define PI_2_1 c[0] + 1.57079632679489661923132169155131424e+00L, /* 3fff921fb54442d18469898cc5100000 */ + +/* pi/2 - PI_2_1 */ +#define PI_2_1t c[1] + 8.84372056613570112025531863263659260e-29L, /* 3fa1c06e0e68948127044533e63a0106 */ +}; + +int32_t __ieee754_rem_pio2l(long double x, long double *y) +{ + long double z, w, t; + double tx[8]; + int64_t exp, n, ix, hx, ixd; + u_int64_t lx, lxd; + + GET_LDOUBLE_WORDS64 (hx, lx, x); + ix = hx & 0x7fffffffffffffffLL; + if (ix <= 0x3fe921fb54442d10LL) /* x in <-pi/4, pi/4> */ + { + y[0] = x; + y[1] = 0; + return 0; + } + + if (ix < 0x4002d97c7f3321d0LL) /* |x| in 0) + { + /* 113 + 93 bit PI is ok */ + z = x - PI_2_1; + y[0] = z - PI_2_1t; + y[1] = (z - y[0]) - PI_2_1t; + return 1; + } + else + { + /* 113 + 93 bit PI is ok */ + z = x + PI_2_1; + y[0] = z + PI_2_1t; + y[1] = (z - y[0]) + PI_2_1t; + return -1; + } + } + + if (ix >= 0x7ff0000000000000LL) /* x is +=oo or NaN */ + { + y[0] = x - x; + y[1] = y[0]; + return 0; + } + + /* Handle large arguments. + We split the 113 bits of the mantissa into 5 24bit integers + stored in a double array. */ + /* Make the IBM extended format 105 bit mantissa look like the ieee854 112 + bit mantissa so the next operatation will give the correct result. */ + EXTRACT_IBM_EXTENDED_MANTISSA (ixd, lxd, exp, x); + exp = exp - 23; + /* This is faster than doing this in floating point, because we + have to convert it to integers anyway and like this we can keep + both integer and floating point units busy. */ + tx [0] = (double)(((ixd >> 25) & 0x7fffff) | 0x800000); + tx [1] = (double)((ixd >> 1) & 0xffffff); + tx [2] = (double)(((ixd << 23) | (lxd >> 41)) & 0xffffff); + tx [3] = (double)((lxd >> 17) & 0xffffff); + tx [4] = (double)((lxd << 7) & 0xffffff); + + n = __kernel_rem_pio2 (tx, tx + 5, exp, ((lxd << 7) & 0xffffff) ? 5 : 4, + 3, two_over_pi); + + /* The result is now stored in 3 double values, we need to convert it into + two long double values. */ + t = (long double) tx [6] + (long double) tx [7]; + w = (long double) tx [5]; + + if (hx >= 0) + { + y[0] = w + t; + y[1] = t - (y[0] - w); + return n; + } + else + { + y[0] = -(w + t); + y[1] = -t - (y[0] + w); + return -n; + } +} diff --git a/sysdeps/ieee754/ldbl-128ibm/e_remainderl.c b/sysdeps/ieee754/ldbl-128ibm/e_remainderl.c new file mode 100644 index 0000000..b7fa68f --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/e_remainderl.c @@ -0,0 +1,78 @@ +/* e_fmodl.c -- long double version of e_fmod.c. + * Conversion to IEEE quad long double by Jakub Jelinek, jj@ultra.linux.cz. + */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* __ieee754_remainderl(x,p) + * Return : + * returns x REM p = x - [x/p]*p as if in infinite + * precise arithmetic, where [x/p] is the (infinite bit) + * integer nearest x/p (in half way case choose the even one). + * Method : + * Based on fmodl() return x-[x/p]chopped*p exactlp. + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const long double zero = 0.0L; +#else +static long double zero = 0.0L; +#endif + + +#ifdef __STDC__ + long double __ieee754_remainderl(long double x, long double p) +#else + long double __ieee754_remainderl(x,p) + long double x,p; +#endif +{ + int64_t hx,hp; + u_int64_t sx,lx,lp; + long double p_half; + + GET_LDOUBLE_WORDS64(hx,lx,x); + GET_LDOUBLE_WORDS64(hp,lp,p); + sx = hx&0x8000000000000000ULL; + hp &= 0x7fffffffffffffffLL; + hx &= 0x7fffffffffffffffLL; + + /* purge off exception values */ + if((hp|(lp&0x7fffffffffffffff))==0) return (x*p)/(x*p); /* p = 0 */ + if((hx>=0x7ff0000000000000LL)|| /* x not finite */ + ((hp>=0x7ff0000000000000LL)&& /* p is NaN */ + (((hp-0x7ff0000000000000LL)|lp)!=0))) + return (x*p)/(x*p); + + + if (hp<=0x7fdfffffffffffffLL) x = __ieee754_fmodl(x,p+p); /* now x < 2p */ + if (((hx-hp)|(lx-lp))==0) return zero*x; + x = fabsl(x); + p = fabsl(p); + if (hp<0x0020000000000000LL) { + if(x+x>p) { + x-=p; + if(x+x>=p) x -= p; + } + } else { + p_half = 0.5L*p; + if(x>p_half) { + x-=p; + if(x>=p_half) x -= p; + } + } + GET_LDOUBLE_MSW64(hx,x); + SET_LDOUBLE_MSW64(x,hx^sx); + return x; +} diff --git a/sysdeps/ieee754/ldbl-128ibm/e_sinhl.c b/sysdeps/ieee754/ldbl-128ibm/e_sinhl.c new file mode 100644 index 0000000..38ae71d --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/e_sinhl.c @@ -0,0 +1,84 @@ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: e_sinh.c,v 1.7 1995/05/10 20:46:13 jtc Exp $"; +#endif + +/* __ieee754_sinh(x) + * Method : + * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2 + * 1. Replace x by |x| (sinh(-x) = -sinh(x)). + * 2. + * E + E/(E+1) + * 0 <= x <= 22 : sinh(x) := --------------, E=expm1(x) + * 2 + * + * 22 <= x <= lnovft : sinh(x) := exp(x)/2 + * lnovft <= x <= ln2ovft: sinh(x) := exp(x/2)/2 * exp(x/2) + * ln2ovft < x : sinh(x) := x*shuge (overflow) + * + * Special cases: + * sinh(x) is |x| if x is +INF, -INF, or NaN. + * only sinh(0)=0 is exact for finite x. + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const long double one = 1.0, shuge = 1.0e307; +#else +static long double one = 1.0, shuge = 1.0e307; +#endif + +#ifdef __STDC__ + long double __ieee754_sinhl(long double x) +#else + long double __ieee754_sinhl(x) + long double x; +#endif +{ + long double t,w,h; + int64_t ix,jx; + + /* High word of |x|. */ + GET_LDOUBLE_MSW64(jx,x); + ix = jx&0x7fffffffffffffffLL; + + /* x is INF or NaN */ + if(ix>=0x7ff0000000000000LL) return x+x; + + h = 0.5; + if (jx<0) h = -h; + /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */ + if (ix < 0x4036000000000000LL) { /* |x|<22 */ + if (ix<0x3e20000000000000LL) /* |x|<2**-29 */ + if(shuge+x>one) return x;/* sinhl(tiny) = tiny with inexact */ + t = __expm1l(fabsl(x)); + if(ix<0x3ff0000000000000LL) return h*(2.0*t-t*t/(t+one)); + return h*(t+t/(t+one)); + } + + /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */ + if (ix < 0x40862e42fefa39efLL) return h*__ieee754_expl(fabsl(x)); + + /* |x| in [log(maxdouble), overflowthresold] */ + if (ix <= 0x408633ce8fb9f87dLL) { + w = __ieee754_expl(0.5*fabsl(x)); + t = h*w; + return t*w; + } + + /* |x| > overflowthresold, sinh(x) overflow */ + return x*shuge; +} diff --git a/sysdeps/ieee754/ldbl-128ibm/e_sqrtl.c b/sysdeps/ieee754/ldbl-128ibm/e_sqrtl.c new file mode 100644 index 0000000..1f533ca --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/e_sqrtl.c @@ -0,0 +1,109 @@ +/* + * IBM Accurate Mathematical Library + * written by International Business Machines Corp. + * Copyright (C) 2001, 2004, 2006 Free Software Foundation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +/*********************************************************************/ +/* MODULE_NAME: uroot.c */ +/* */ +/* FUNCTION: usqrt */ +/* */ +/* FILES NEEDED: dla.h endian.h mydefs.h uroot.h */ +/* uroot.tbl */ +/* */ +/* An ultimate sqrt routine. Given an IEEE double machine number x */ +/* it computes the correctly rounded (to nearest) value of square */ +/* root of x. */ +/* Assumption: Machine arithmetic operations are performed in */ +/* round to nearest mode of IEEE 754 standard. */ +/* */ +/*********************************************************************/ + +#include + +typedef unsigned int int4; +typedef union {int4 i[4]; long double x; double d[2]; } mynumber; + +static const mynumber + t512 = {{0x5ff00000, 0x00000000, 0x00000000, 0x00000000 }}, /* 2^512 */ + tm256 = {{0x2ff00000, 0x00000000, 0x00000000, 0x00000000 }}; /* 2^-256 */ +static const double +two54 = 1.80143985094819840000e+16, /* 0x4350000000000000 */ +twom54 = 5.55111512312578270212e-17; /* 0x3C90000000000000 */ + +/*********************************************************************/ +/* An ultimate sqrt routine. Given an IEEE double machine number x */ +/* it computes the correctly rounded (to nearest) value of square */ +/* root of x. */ +/*********************************************************************/ +long double __ieee754_sqrtl(long double x) +{ + static const long double big = 134217728.0, big1 = 134217729.0; + long double t,s,i; + mynumber a,c; + int4 k, l, m; + int n; + double d; + + a.x=x; + k=a.i[0] & 0x7fffffff; + /*----------------- 2^-1022 <= | x |< 2^1024 -----------------*/ + if (k>0x000fffff && k<0x7ff00000) { + if (x < 0) return (big1-big1)/(big-big); + l = (k&0x001fffff)|0x3fe00000; + if (((a.i[2] & 0x7fffffff) | a.i[3]) != 0) { + n = (int) ((l - k) * 2) >> 21; + m = (a.i[2] >> 20) & 0x7ff; + if (m == 0) { + a.d[1] *= two54; + m = ((a.i[2] >> 20) & 0x7ff) - 54; + } + m += n; + if (m > 0) + a.i[2] = (a.i[2] & 0x800fffff) | (m << 20); + else if (m <= -54) { + a.i[2] &= 0x80000000; + a.i[3] = 0; + } else { + m += 54; + a.i[2] = (a.i[2] & 0x800fffff) | (m << 20); + a.d[1] *= twom54; + } + } + a.i[0] = l; + s = a.x; + d = __ieee754_sqrt (a.d[0]); + c.i[0] = 0x20000000+((k&0x7fe00000)>>1); + c.i[1] = 0; + c.i[2] = 0; + c.i[3] = 0; + i = d; + t = 0.5L * (i + s / i); + i = 0.5L * (t + s / t); + return c.x * i; + } + else { + if (k>=0x7ff00000) { + if (a.i[0] == 0xfff00000 && a.i[1] == 0) + return (big1-big1)/(big-big); /* sqrt (-Inf) = NaN. */ + return x; /* sqrt (NaN) = NaN, sqrt (+Inf) = +Inf. */ + } + if (x == 0) return x; + if (x < 0) return (big1-big1)/(big-big); + return tm256.x*__ieee754_sqrtl(x*t512.x); + } +} diff --git a/sysdeps/ieee754/ldbl-128ibm/ieee754.h b/sysdeps/ieee754/ldbl-128ibm/ieee754.h new file mode 100644 index 0000000..94a2091 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/ieee754.h @@ -0,0 +1,210 @@ +/* Copyright (C) 1992, 1995, 1996, 1999, 2004, 2006 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _IEEE754_H + +#define _IEEE754_H 1 +#include + +#include + +__BEGIN_DECLS + +union ieee754_float + { + float f; + + /* This is the IEEE 754 single-precision format. */ + struct + { +#if __BYTE_ORDER == __BIG_ENDIAN + unsigned int negative:1; + unsigned int exponent:8; + unsigned int mantissa:23; +#endif /* Big endian. */ +#if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned int mantissa:23; + unsigned int exponent:8; + unsigned int negative:1; +#endif /* Little endian. */ + } ieee; + + /* This format makes it easier to see if a NaN is a signalling NaN. */ + struct + { +#if __BYTE_ORDER == __BIG_ENDIAN + unsigned int negative:1; + unsigned int exponent:8; + unsigned int quiet_nan:1; + unsigned int mantissa:22; +#endif /* Big endian. */ +#if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned int mantissa:22; + unsigned int quiet_nan:1; + unsigned int exponent:8; + unsigned int negative:1; +#endif /* Little endian. */ + } ieee_nan; + }; + +#define IEEE754_FLOAT_BIAS 0x7f /* Added to exponent. */ + + +union ieee754_double + { + double d; + + /* This is the IEEE 754 double-precision format. */ + struct + { +#if __BYTE_ORDER == __BIG_ENDIAN + unsigned int negative:1; + unsigned int exponent:11; + /* Together these comprise the mantissa. */ + unsigned int mantissa0:20; + unsigned int mantissa1:32; +#endif /* Big endian. */ +#if __BYTE_ORDER == __LITTLE_ENDIAN + /* Together these comprise the mantissa. */ + unsigned int mantissa1:32; + unsigned int mantissa0:20; + unsigned int exponent:11; + unsigned int negative:1; +#endif /* Little endian. */ + } ieee; + + /* This format makes it easier to see if a NaN is a signalling NaN. */ + struct + { +#if __BYTE_ORDER == __BIG_ENDIAN + unsigned int negative:1; + unsigned int exponent:11; + unsigned int quiet_nan:1; + /* Together these comprise the mantissa. */ + unsigned int mantissa0:19; + unsigned int mantissa1:32; +#else + /* Together these comprise the mantissa. */ + unsigned int mantissa1:32; + unsigned int mantissa0:19; + unsigned int quiet_nan:1; + unsigned int exponent:11; + unsigned int negative:1; +#endif + } ieee_nan; + }; + +#define IEEE754_DOUBLE_BIAS 0x3ff /* Added to exponent. */ + + +union ieee854_long_double + { + long double d; + + /* This is the IEEE 854 quad-precision format. */ + struct + { +#if __BYTE_ORDER == __BIG_ENDIAN + unsigned int negative:1; + unsigned int exponent:15; + /* Together these comprise the mantissa. */ + unsigned int mantissa0:16; + unsigned int mantissa1:32; + unsigned int mantissa2:32; + unsigned int mantissa3:32; +#endif /* Big endian. */ +#if __BYTE_ORDER == __LITTLE_ENDIAN + /* Together these comprise the mantissa. */ + unsigned int mantissa3:32; + unsigned int mantissa2:32; + unsigned int mantissa1:32; + unsigned int mantissa0:16; + unsigned int exponent:15; + unsigned int negative:1; +#endif /* Little endian. */ + } ieee; + + /* This format makes it easier to see if a NaN is a signalling NaN. */ + struct + { +#if __BYTE_ORDER == __BIG_ENDIAN + unsigned int negative:1; + unsigned int exponent:15; + unsigned int quiet_nan:1; + /* Together these comprise the mantissa. */ + unsigned int mantissa0:15; + unsigned int mantissa1:32; + unsigned int mantissa2:32; + unsigned int mantissa3:32; +#else + /* Together these comprise the mantissa. */ + unsigned int mantissa3:32; + unsigned int mantissa2:32; + unsigned int mantissa1:32; + unsigned int mantissa0:15; + unsigned int quiet_nan:1; + unsigned int exponent:15; + unsigned int negative:1; +#endif + } ieee_nan; + }; + +#define IEEE854_LONG_DOUBLE_BIAS 0x3fff /* Added to exponent. */ + + +/* IBM extended format for long double. + + Each long double is made up of two IEEE doubles. The value of the + long double is the sum of the values of the two parts. The most + significant part is required to be the value of the long double + rounded to the nearest double, as specified by IEEE. For Inf + values, the least significant part is required to be one of +0.0 or + -0.0. No other requirements are made; so, for example, 1.0 may be + represented as (1.0, +0.0) or (1.0, -0.0), and the low part of a + NaN is don't-care. */ + +union ibm_extended_long_double + { + long double d; + double dd[2]; + + /* This is the IBM extended format long double. */ + struct + { /* Big endian. There is no other. */ + + unsigned int negative:1; + unsigned int exponent:11; + /* Together Mantissa0-3 comprise the mantissa. */ + unsigned int mantissa0:20; + unsigned int mantissa1:32; + + unsigned int negative2:1; + unsigned int exponent2:11; + /* There is an implied 1 here? */ + /* Together these comprise the mantissa. */ + unsigned int mantissa2:20; + unsigned int mantissa3:32; + } ieee; + }; + +#define IBM_EXTENDED_LONG_DOUBLE_BIAS 0x3ff /* Added to exponent. */ + +__END_DECLS + +#endif /* ieee754.h */ diff --git a/sysdeps/ieee754/ldbl-128ibm/k_cosl.c b/sysdeps/ieee754/ldbl-128ibm/k_cosl.c new file mode 100644 index 0000000..3baf8b7 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/k_cosl.c @@ -0,0 +1,128 @@ +/* Quad-precision floating point cosine on <-pi/4,pi/4>. + Copyright (C) 1999,2004,2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include "math.h" +#include "math_private.h" + +static const long double c[] = { +#define ONE c[0] + 1.00000000000000000000000000000000000E+00L, /* 3fff0000000000000000000000000000 */ + +/* cos x ~ ONE + x^2 ( SCOS1 + SCOS2 * x^2 + ... + SCOS4 * x^6 + SCOS5 * x^8 ) + x in <0,1/256> */ +#define SCOS1 c[1] +#define SCOS2 c[2] +#define SCOS3 c[3] +#define SCOS4 c[4] +#define SCOS5 c[5] +-5.00000000000000000000000000000000000E-01L, /* bffe0000000000000000000000000000 */ + 4.16666666666666666666666666556146073E-02L, /* 3ffa5555555555555555555555395023 */ +-1.38888888888888888888309442601939728E-03L, /* bff56c16c16c16c16c16a566e42c0375 */ + 2.48015873015862382987049502531095061E-05L, /* 3fefa01a01a019ee02dcf7da2d6d5444 */ +-2.75573112601362126593516899592158083E-07L, /* bfe927e4f5dce637cb0b54908754bde0 */ + +/* cos x ~ ONE + x^2 ( COS1 + COS2 * x^2 + ... + COS7 * x^12 + COS8 * x^14 ) + x in <0,0.1484375> */ +#define COS1 c[6] +#define COS2 c[7] +#define COS3 c[8] +#define COS4 c[9] +#define COS5 c[10] +#define COS6 c[11] +#define COS7 c[12] +#define COS8 c[13] +-4.99999999999999999999999999999999759E-01L, /* bffdfffffffffffffffffffffffffffb */ + 4.16666666666666666666666666651287795E-02L, /* 3ffa5555555555555555555555516f30 */ +-1.38888888888888888888888742314300284E-03L, /* bff56c16c16c16c16c16c16a463dfd0d */ + 2.48015873015873015867694002851118210E-05L, /* 3fefa01a01a01a01a0195cebe6f3d3a5 */ +-2.75573192239858811636614709689300351E-07L, /* bfe927e4fb7789f5aa8142a22044b51f */ + 2.08767569877762248667431926878073669E-09L, /* 3fe21eed8eff881d1e9262d7adff4373 */ +-1.14707451049343817400420280514614892E-11L, /* bfda9397496922a9601ed3d4ca48944b */ + 4.77810092804389587579843296923533297E-14L, /* 3fd2ae5f8197cbcdcaf7c3fb4523414c */ + +/* sin x ~ ONE * x + x^3 ( SSIN1 + SSIN2 * x^2 + ... + SSIN4 * x^6 + SSIN5 * x^8 ) + x in <0,1/256> */ +#define SSIN1 c[14] +#define SSIN2 c[15] +#define SSIN3 c[16] +#define SSIN4 c[17] +#define SSIN5 c[18] +-1.66666666666666666666666666666666659E-01L, /* bffc5555555555555555555555555555 */ + 8.33333333333333333333333333146298442E-03L, /* 3ff81111111111111111111110fe195d */ +-1.98412698412698412697726277416810661E-04L, /* bff2a01a01a01a01a019e7121e080d88 */ + 2.75573192239848624174178393552189149E-06L, /* 3fec71de3a556c640c6aaa51aa02ab41 */ +-2.50521016467996193495359189395805639E-08L, /* bfe5ae644ee90c47dc71839de75b2787 */ +}; + +#define SINCOSL_COS_HI 0 +#define SINCOSL_COS_LO 1 +#define SINCOSL_SIN_HI 2 +#define SINCOSL_SIN_LO 3 +extern const long double __sincosl_table[]; + +long double +__kernel_cosl(long double x, long double y) +{ + long double h, l, z, sin_l, cos_l_m1; + int64_t ix; + u_int32_t tix, hix, index; + GET_LDOUBLE_MSW64 (ix, x); + tix = ((u_int64_t)ix) >> 32; + tix &= ~0x80000000; /* tix = |x|'s high 32 bits */ + if (tix < 0x3fc30000) /* |x| < 0.1484375 */ + { + /* Argument is small enough to approximate it by a Chebyshev + polynomial of degree 16. */ + if (tix < 0x3c600000) /* |x| < 2^-57 */ + if (!((int)x)) return ONE; /* generate inexact */ + z = x * x; + return ONE + (z*(COS1+z*(COS2+z*(COS3+z*(COS4+ + z*(COS5+z*(COS6+z*(COS7+z*COS8)))))))); + } + else + { + /* So that we don't have to use too large polynomial, we find + l and h such that x = l + h, where fabsl(l) <= 1.0/256 with 83 + possible values for h. We look up cosl(h) and sinl(h) in + pre-computed tables, compute cosl(l) and sinl(l) using a + Chebyshev polynomial of degree 10(11) and compute + cosl(h+l) = cosl(h)cosl(l) - sinl(h)sinl(l). */ + index = 0x3fe - (tix >> 20); + hix = (tix + (0x200 << index)) & (0xfffffc00 << index); + x = fabsl (x); + switch (index) + { + case 0: index = ((45 << 14) + hix - 0x3fe00000) >> 12; break; + case 1: index = ((13 << 15) + hix - 0x3fd00000) >> 13; break; + default: + case 2: index = (hix - 0x3fc30000) >> 14; break; + } + + SET_LDOUBLE_WORDS64(h, ((u_int64_t)hix) << 32, 0); + l = y - (h - x); + z = l * l; + sin_l = l*(ONE+z*(SSIN1+z*(SSIN2+z*(SSIN3+z*(SSIN4+z*SSIN5))))); + cos_l_m1 = z*(SCOS1+z*(SCOS2+z*(SCOS3+z*(SCOS4+z*SCOS5)))); + return __sincosl_table [index + SINCOSL_COS_HI] + + (__sincosl_table [index + SINCOSL_COS_LO] + - (__sincosl_table [index + SINCOSL_SIN_HI] * sin_l + - __sincosl_table [index + SINCOSL_COS_HI] * cos_l_m1)); + } +} diff --git a/sysdeps/ieee754/ldbl-128ibm/k_sincosl.c b/sysdeps/ieee754/ldbl-128ibm/k_sincosl.c new file mode 100644 index 0000000..1cea6fe --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/k_sincosl.c @@ -0,0 +1,163 @@ +/* Quad-precision floating point sine and cosine on <-pi/4,pi/4>. + Copyright (C) 1999,2004,2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include "math.h" +#include "math_private.h" + +static const long double c[] = { +#define ONE c[0] + 1.00000000000000000000000000000000000E+00L, /* 3fff0000000000000000000000000000 */ + +/* cos x ~ ONE + x^2 ( SCOS1 + SCOS2 * x^2 + ... + SCOS4 * x^6 + SCOS5 * x^8 ) + x in <0,1/256> */ +#define SCOS1 c[1] +#define SCOS2 c[2] +#define SCOS3 c[3] +#define SCOS4 c[4] +#define SCOS5 c[5] +-5.00000000000000000000000000000000000E-01L, /* bffe0000000000000000000000000000 */ + 4.16666666666666666666666666556146073E-02L, /* 3ffa5555555555555555555555395023 */ +-1.38888888888888888888309442601939728E-03L, /* bff56c16c16c16c16c16a566e42c0375 */ + 2.48015873015862382987049502531095061E-05L, /* 3fefa01a01a019ee02dcf7da2d6d5444 */ +-2.75573112601362126593516899592158083E-07L, /* bfe927e4f5dce637cb0b54908754bde0 */ + +/* cos x ~ ONE + x^2 ( COS1 + COS2 * x^2 + ... + COS7 * x^12 + COS8 * x^14 ) + x in <0,0.1484375> */ +#define COS1 c[6] +#define COS2 c[7] +#define COS3 c[8] +#define COS4 c[9] +#define COS5 c[10] +#define COS6 c[11] +#define COS7 c[12] +#define COS8 c[13] +-4.99999999999999999999999999999999759E-01L, /* bffdfffffffffffffffffffffffffffb */ + 4.16666666666666666666666666651287795E-02L, /* 3ffa5555555555555555555555516f30 */ +-1.38888888888888888888888742314300284E-03L, /* bff56c16c16c16c16c16c16a463dfd0d */ + 2.48015873015873015867694002851118210E-05L, /* 3fefa01a01a01a01a0195cebe6f3d3a5 */ +-2.75573192239858811636614709689300351E-07L, /* bfe927e4fb7789f5aa8142a22044b51f */ + 2.08767569877762248667431926878073669E-09L, /* 3fe21eed8eff881d1e9262d7adff4373 */ +-1.14707451049343817400420280514614892E-11L, /* bfda9397496922a9601ed3d4ca48944b */ + 4.77810092804389587579843296923533297E-14L, /* 3fd2ae5f8197cbcdcaf7c3fb4523414c */ + +/* sin x ~ ONE * x + x^3 ( SSIN1 + SSIN2 * x^2 + ... + SSIN4 * x^6 + SSIN5 * x^8 ) + x in <0,1/256> */ +#define SSIN1 c[14] +#define SSIN2 c[15] +#define SSIN3 c[16] +#define SSIN4 c[17] +#define SSIN5 c[18] +-1.66666666666666666666666666666666659E-01L, /* bffc5555555555555555555555555555 */ + 8.33333333333333333333333333146298442E-03L, /* 3ff81111111111111111111110fe195d */ +-1.98412698412698412697726277416810661E-04L, /* bff2a01a01a01a01a019e7121e080d88 */ + 2.75573192239848624174178393552189149E-06L, /* 3fec71de3a556c640c6aaa51aa02ab41 */ +-2.50521016467996193495359189395805639E-08L, /* bfe5ae644ee90c47dc71839de75b2787 */ + +/* sin x ~ ONE * x + x^3 ( SIN1 + SIN2 * x^2 + ... + SIN7 * x^12 + SIN8 * x^14 ) + x in <0,0.1484375> */ +#define SIN1 c[19] +#define SIN2 c[20] +#define SIN3 c[21] +#define SIN4 c[22] +#define SIN5 c[23] +#define SIN6 c[24] +#define SIN7 c[25] +#define SIN8 c[26] +-1.66666666666666666666666666666666538e-01L, /* bffc5555555555555555555555555550 */ + 8.33333333333333333333333333307532934e-03L, /* 3ff811111111111111111111110e7340 */ +-1.98412698412698412698412534478712057e-04L, /* bff2a01a01a01a01a01a019e7a626296 */ + 2.75573192239858906520896496653095890e-06L, /* 3fec71de3a556c7338fa38527474b8f5 */ +-2.50521083854417116999224301266655662e-08L, /* bfe5ae64567f544e16c7de65c2ea551f */ + 1.60590438367608957516841576404938118e-10L, /* 3fde6124613a811480538a9a41957115 */ +-7.64716343504264506714019494041582610e-13L, /* bfd6ae7f3d5aef30c7bc660b060ef365 */ + 2.81068754939739570236322404393398135e-15L, /* 3fce9510115aabf87aceb2022a9a9180 */ +}; + +#define SINCOSL_COS_HI 0 +#define SINCOSL_COS_LO 1 +#define SINCOSL_SIN_HI 2 +#define SINCOSL_SIN_LO 3 +extern const long double __sincosl_table[]; + +void +__kernel_sincosl(long double x, long double y, long double *sinx, long double *cosx, int iy) +{ + long double h, l, z, sin_l, cos_l_m1; + int64_t ix; + u_int32_t tix, hix, index; + GET_LDOUBLE_MSW64 (ix, x); + tix = ((u_int64_t)ix) >> 32; + tix &= ~0x80000000; /* tix = |x|'s high 32 bits */ + if (tix < 0x3fc30000) /* |x| < 0.1484375 */ + { + /* Argument is small enough to approximate it by a Chebyshev + polynomial of degree 16(17). */ + if (tix < 0x3c600000) /* |x| < 2^-57 */ + if (!((int)x)) /* generate inexact */ + { + *sinx = x; + *cosx = ONE; + return; + } + z = x * x; + *sinx = x + (x * (z*(SIN1+z*(SIN2+z*(SIN3+z*(SIN4+ + z*(SIN5+z*(SIN6+z*(SIN7+z*SIN8))))))))); + *cosx = ONE + (z*(COS1+z*(COS2+z*(COS3+z*(COS4+ + z*(COS5+z*(COS6+z*(COS7+z*COS8)))))))); + } + else + { + /* So that we don't have to use too large polynomial, we find + l and h such that x = l + h, where fabsl(l) <= 1.0/256 with 83 + possible values for h. We look up cosl(h) and sinl(h) in + pre-computed tables, compute cosl(l) and sinl(l) using a + Chebyshev polynomial of degree 10(11) and compute + sinl(h+l) = sinl(h)cosl(l) + cosl(h)sinl(l) and + cosl(h+l) = cosl(h)cosl(l) - sinl(h)sinl(l). */ + index = 0x3fe - (tix >> 20); + hix = (tix + (0x2000 << index)) & (0xffffc000 << index); + x = fabsl (x); + switch (index) + { + case 0: index = ((45 << 14) + hix - 0x3fe00000) >> 12; break; + case 1: index = ((13 << 15) + hix - 0x3fd00000) >> 13; break; + default: + case 2: index = (hix - 0x3fc30000) >> 14; break; + } + + SET_LDOUBLE_WORDS64(h, ((u_int64_t)hix) << 32, 0); + if (iy) + l = y - (h - x); + else + l = x - h; + z = l * l; + sin_l = l*(ONE+z*(SSIN1+z*(SSIN2+z*(SSIN3+z*(SSIN4+z*SSIN5))))); + cos_l_m1 = z*(SCOS1+z*(SCOS2+z*(SCOS3+z*(SCOS4+z*SCOS5)))); + z = __sincosl_table [index + SINCOSL_SIN_HI] + + (__sincosl_table [index + SINCOSL_SIN_LO] + + (__sincosl_table [index + SINCOSL_SIN_HI] * cos_l_m1) + + (__sincosl_table [index + SINCOSL_COS_HI] * sin_l)); + *sinx = (ix < 0) ? -z : z; + *cosx = __sincosl_table [index + SINCOSL_COS_HI] + + (__sincosl_table [index + SINCOSL_COS_LO] + - (__sincosl_table [index + SINCOSL_SIN_HI] * sin_l + - __sincosl_table [index + SINCOSL_COS_HI] * cos_l_m1)); + } +} diff --git a/sysdeps/ieee754/ldbl-128ibm/k_sinl.c b/sysdeps/ieee754/ldbl-128ibm/k_sinl.c new file mode 100644 index 0000000..c4dce26 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/k_sinl.c @@ -0,0 +1,132 @@ +/* Quad-precision floating point sine on <-pi/4,pi/4>. + Copyright (C) 1999,2004,2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include "math.h" +#include "math_private.h" + +static const long double c[] = { +#define ONE c[0] + 1.00000000000000000000000000000000000E+00L, /* 3fff0000000000000000000000000000 */ + +/* cos x ~ ONE + x^2 ( SCOS1 + SCOS2 * x^2 + ... + SCOS4 * x^6 + SCOS5 * x^8 ) + x in <0,1/256> */ +#define SCOS1 c[1] +#define SCOS2 c[2] +#define SCOS3 c[3] +#define SCOS4 c[4] +#define SCOS5 c[5] +-5.00000000000000000000000000000000000E-01L, /* bffe0000000000000000000000000000 */ + 4.16666666666666666666666666556146073E-02L, /* 3ffa5555555555555555555555395023 */ +-1.38888888888888888888309442601939728E-03L, /* bff56c16c16c16c16c16a566e42c0375 */ + 2.48015873015862382987049502531095061E-05L, /* 3fefa01a01a019ee02dcf7da2d6d5444 */ +-2.75573112601362126593516899592158083E-07L, /* bfe927e4f5dce637cb0b54908754bde0 */ + +/* sin x ~ ONE * x + x^3 ( SIN1 + SIN2 * x^2 + ... + SIN7 * x^12 + SIN8 * x^14 ) + x in <0,0.1484375> */ +#define SIN1 c[6] +#define SIN2 c[7] +#define SIN3 c[8] +#define SIN4 c[9] +#define SIN5 c[10] +#define SIN6 c[11] +#define SIN7 c[12] +#define SIN8 c[13] +-1.66666666666666666666666666666666538e-01L, /* bffc5555555555555555555555555550 */ + 8.33333333333333333333333333307532934e-03L, /* 3ff811111111111111111111110e7340 */ +-1.98412698412698412698412534478712057e-04L, /* bff2a01a01a01a01a01a019e7a626296 */ + 2.75573192239858906520896496653095890e-06L, /* 3fec71de3a556c7338fa38527474b8f5 */ +-2.50521083854417116999224301266655662e-08L, /* bfe5ae64567f544e16c7de65c2ea551f */ + 1.60590438367608957516841576404938118e-10L, /* 3fde6124613a811480538a9a41957115 */ +-7.64716343504264506714019494041582610e-13L, /* bfd6ae7f3d5aef30c7bc660b060ef365 */ + 2.81068754939739570236322404393398135e-15L, /* 3fce9510115aabf87aceb2022a9a9180 */ + +/* sin x ~ ONE * x + x^3 ( SSIN1 + SSIN2 * x^2 + ... + SSIN4 * x^6 + SSIN5 * x^8 ) + x in <0,1/256> */ +#define SSIN1 c[14] +#define SSIN2 c[15] +#define SSIN3 c[16] +#define SSIN4 c[17] +#define SSIN5 c[18] +-1.66666666666666666666666666666666659E-01L, /* bffc5555555555555555555555555555 */ + 8.33333333333333333333333333146298442E-03L, /* 3ff81111111111111111111110fe195d */ +-1.98412698412698412697726277416810661E-04L, /* bff2a01a01a01a01a019e7121e080d88 */ + 2.75573192239848624174178393552189149E-06L, /* 3fec71de3a556c640c6aaa51aa02ab41 */ +-2.50521016467996193495359189395805639E-08L, /* bfe5ae644ee90c47dc71839de75b2787 */ +}; + +#define SINCOSL_COS_HI 0 +#define SINCOSL_COS_LO 1 +#define SINCOSL_SIN_HI 2 +#define SINCOSL_SIN_LO 3 +extern const long double __sincosl_table[]; + +long double +__kernel_sinl(long double x, long double y, int iy) +{ + long double h, l, z, sin_l, cos_l_m1; + int64_t ix; + u_int32_t tix, hix, index; + GET_LDOUBLE_MSW64 (ix, x); + tix = ((u_int64_t)ix) >> 32; + tix &= ~0x80000000; /* tix = |x|'s high 32 bits */ + if (tix < 0x3fc30000) /* |x| < 0.1484375 */ + { + /* Argument is small enough to approximate it by a Chebyshev + polynomial of degree 17. */ + if (tix < 0x3c600000) /* |x| < 2^-57 */ + if (!((int)x)) return x; /* generate inexact */ + z = x * x; + return x + (x * (z*(SIN1+z*(SIN2+z*(SIN3+z*(SIN4+ + z*(SIN5+z*(SIN6+z*(SIN7+z*SIN8))))))))); + } + else + { + /* So that we don't have to use too large polynomial, we find + l and h such that x = l + h, where fabsl(l) <= 1.0/256 with 83 + possible values for h. We look up cosl(h) and sinl(h) in + pre-computed tables, compute cosl(l) and sinl(l) using a + Chebyshev polynomial of degree 10(11) and compute + sinl(h+l) = sinl(h)cosl(l) + cosl(h)sinl(l). */ + index = 0x3fe - (tix >> 20); + hix = (tix + (0x2000 << index)) & (0xffffc000 << index); + x = fabsl (x); + switch (index) + { + case 0: index = ((45 << 14) + hix - 0x3fe00000) >> 12; break; + case 1: index = ((13 << 15) + hix - 0x3fd00000) >> 13; break; + default: + case 2: index = (hix - 0x3fc30000) >> 14; break; + } + + SET_LDOUBLE_WORDS64(h, ((u_int64_t)hix) << 32, 0); + if (iy) + l = y - (h - x); + else + l = x - h; + z = l * l; + sin_l = l*(ONE+z*(SSIN1+z*(SSIN2+z*(SSIN3+z*(SSIN4+z*SSIN5))))); + cos_l_m1 = z*(SCOS1+z*(SCOS2+z*(SCOS3+z*(SCOS4+z*SCOS5)))); + z = __sincosl_table [index + SINCOSL_SIN_HI] + + (__sincosl_table [index + SINCOSL_SIN_LO] + + (__sincosl_table [index + SINCOSL_SIN_HI] * cos_l_m1) + + (__sincosl_table [index + SINCOSL_COS_HI] * sin_l)); + return (ix < 0) ? -z : z; + } +} diff --git a/sysdeps/ieee754/ldbl-128ibm/k_tanl.c b/sysdeps/ieee754/ldbl-128ibm/k_tanl.c new file mode 100644 index 0000000..6c45b2f --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/k_tanl.c @@ -0,0 +1,164 @@ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + Long double expansions are + Copyright (C) 2001 Stephen L. Moshier + and are incorporated herein by permission of the author. The author + reserves the right to distribute this material elsewhere under different + copying permissions. These modifications are distributed here under + the following terms: + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* __kernel_tanl( x, y, k ) + * kernel tan function on [-pi/4, pi/4], pi/4 ~ 0.7854 + * Input x is assumed to be bounded by ~pi/4 in magnitude. + * Input y is the tail of x. + * Input k indicates whether tan (if k=1) or + * -1/tan (if k= -1) is returned. + * + * Algorithm + * 1. Since tan(-x) = -tan(x), we need only to consider positive x. + * 2. if x < 2^-57, return x with inexact if x!=0. + * 3. tan(x) is approximated by a rational form x + x^3 / 3 + x^5 R(x^2) + * on [0,0.67433]. + * + * Note: tan(x+y) = tan(x) + tan'(x)*y + * ~ tan(x) + (1+x*x)*y + * Therefore, for better accuracy in computing tan(x+y), let + * r = x^3 * R(x^2) + * then + * tan(x+y) = x + (x^3 / 3 + (x^2 *(r+y)+y)) + * + * 4. For x in [0.67433,pi/4], let y = pi/4 - x, then + * tan(x) = tan(pi/4-y) = (1-tan(y))/(1+tan(y)) + * = 1 - 2*(tan(y) - (tan(y)^2)/(1+tan(y))) + */ + +#include "math.h" +#include "math_private.h" +#ifdef __STDC__ +static const long double +#else +static long double +#endif + one = 1.0L, + pio4hi = 7.8539816339744830961566084581987569936977E-1L, + pio4lo = 2.1679525325309452561992610065108379921906E-35L, + + /* tan x = x + x^3 / 3 + x^5 T(x^2)/U(x^2) + 0 <= x <= 0.6743316650390625 + Peak relative error 8.0e-36 */ + TH = 3.333333333333333333333333333333333333333E-1L, + T0 = -1.813014711743583437742363284336855889393E7L, + T1 = 1.320767960008972224312740075083259247618E6L, + T2 = -2.626775478255838182468651821863299023956E4L, + T3 = 1.764573356488504935415411383687150199315E2L, + T4 = -3.333267763822178690794678978979803526092E-1L, + + U0 = -1.359761033807687578306772463253710042010E8L, + U1 = 6.494370630656893175666729313065113194784E7L, + U2 = -4.180787672237927475505536849168729386782E6L, + U3 = 8.031643765106170040139966622980914621521E4L, + U4 = -5.323131271912475695157127875560667378597E2L; + /* 1.000000000000000000000000000000000000000E0 */ + + +#ifdef __STDC__ +long double +__kernel_tanl (long double x, long double y, int iy) +#else +long double +__kernel_tanl (x, y, iy) + long double x, y; + int iy; +#endif +{ + long double z, r, v, w, s; + int32_t ix, sign; + ieee854_long_double_shape_type u, u1; + + u.value = x; + ix = u.parts32.w0 & 0x7fffffff; + if (ix < 0x3c600000) /* x < 2**-57 */ + { + if ((int) x == 0) + { /* generate inexact */ + if ((ix | u.parts32.w1 | (u.parts32.w2 & 0x7fffffff) | u.parts32.w3 + | (iy + 1)) == 0) + return one / fabs (x); + else + return (iy == 1) ? x : -one / x; + } + } + if (ix >= 0x3fe59420) /* |x| >= 0.6743316650390625 */ + { + if ((u.parts32.w0 & 0x80000000) != 0) + { + x = -x; + y = -y; + sign = -1; + } + else + sign = 1; + z = pio4hi - x; + w = pio4lo - y; + x = z + w; + y = 0.0; + } + z = x * x; + r = T0 + z * (T1 + z * (T2 + z * (T3 + z * T4))); + v = U0 + z * (U1 + z * (U2 + z * (U3 + z * (U4 + z)))); + r = r / v; + + s = z * x; + r = y + z * (s * r + y); + r += TH * s; + w = x + r; + if (ix >= 0x3fe59420) + { + v = (long double) iy; + w = (v - 2.0 * (x - (w * w / (w + v) - r))); + if (sign < 0) + w = -w; + return w; + } + if (iy == 1) + return w; + else + { /* if allow error up to 2 ulp, + simply return -1.0/(x+r) here */ + /* compute -1.0/(x+r) accurately */ + u1.value = w; + u1.parts32.w2 = 0; + u1.parts32.w3 = 0; + v = r - (u1.value - x); /* u1+v = r+x */ + z = -1.0 / w; + u.value = z; + u.parts32.w2 = 0; + u.parts32.w3 = 0; + s = 1.0 + u.value * u1.value; + return u.value + z * (s + u.value * v); + } +} diff --git a/sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c b/sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c new file mode 100644 index 0000000..18a2e67 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c @@ -0,0 +1,175 @@ +/* Copyright (C) 1995,1996,1997,1998,1999,2002,2003,2006 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include "gmp.h" +#include "gmp-impl.h" +#include "longlong.h" +#include +#include +#include +#include + +/* Convert a `long double' in IBM extended format to a multi-precision + integer representing the significand scaled up by its number of + bits (106 for long double) and an integral power of two (MPN + frexpl). */ + +mp_size_t +__mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size, + int *expt, int *is_neg, + long double value) +{ + union ibm_extended_long_double u; + unsigned long long hi, lo; + int ediff; + u.d = value; + + *is_neg = u.ieee.negative; + *expt = (int) u.ieee.exponent - IBM_EXTENDED_LONG_DOUBLE_BIAS; + + lo = ((long long) u.ieee.mantissa2 << 32) | u.ieee.mantissa3; + hi = ((long long) u.ieee.mantissa0 << 32) | u.ieee.mantissa1; + /* If the lower double is not a denomal or zero then set the hidden + 53rd bit. */ + if (u.ieee.exponent2 > 0) + { + lo |= 1LL << 52; + + /* The lower double is normalized separately from the upper. We may + need to adjust the lower manitissa to reflect this. */ + ediff = u.ieee.exponent - u.ieee.exponent2; + if (ediff > 53) + lo = lo >> (ediff-53); + } + /* The high double may be rounded and the low double reflects the + difference between the long double and the rounded high double + value. This is indicated by a differnce between the signs of the + high and low doubles. */ + if ((u.ieee.negative != u.ieee.negative2) + && ((u.ieee.exponent2 != 0) && (lo != 0L))) + { + lo = (1ULL << 53) - lo; + if (hi == 0LL) + { + /* we have a borrow from the hidden bit, so shift left 1. */ + hi = 0x0ffffffffffffeLL | (lo >> 51); + lo = 0x1fffffffffffffLL & (lo << 1); + (*expt)--; + } + else + hi--; + } +#if BITS_PER_MP_LIMB == 32 + /* Combine the mantissas to be contiguous. */ + res_ptr[0] = lo; + res_ptr[1] = (hi << (53 - 32)) | (lo >> 32); + res_ptr[2] = hi >> 11; + res_ptr[3] = hi >> (32 + 11); + #define N 4 +#elif BITS_PER_MP_LIMB == 64 + /* Combine the two mantissas to be contiguous. */ + res_ptr[0] = (hi << 53) | lo; + res_ptr[1] = hi >> 11; + #define N 2 +#else + #error "mp_limb size " BITS_PER_MP_LIMB "not accounted for" +#endif +/* The format does not fill the last limb. There are some zeros. */ +#define NUM_LEADING_ZEROS (BITS_PER_MP_LIMB \ + - (LDBL_MANT_DIG - ((N - 1) * BITS_PER_MP_LIMB))) + + if (u.ieee.exponent == 0) + { + /* A biased exponent of zero is a special case. + Either it is a zero or it is a denormal number. */ + if (res_ptr[0] == 0 && res_ptr[1] == 0 + && res_ptr[N - 2] == 0 && res_ptr[N - 1] == 0) /* Assumes N<=4. */ + /* It's zero. */ + *expt = 0; + else + { + /* It is a denormal number, meaning it has no implicit leading + one bit, and its exponent is in fact the format minimum. */ + int cnt; + +#if N == 2 + if (res_ptr[N - 1] != 0) + { + count_leading_zeros (cnt, res_ptr[N - 1]); + cnt -= NUM_LEADING_ZEROS; + res_ptr[N - 1] = res_ptr[N - 1] << cnt + | (res_ptr[0] >> (BITS_PER_MP_LIMB - cnt)); + res_ptr[0] <<= cnt; + *expt = LDBL_MIN_EXP - 1 - cnt; + } + else + { + count_leading_zeros (cnt, res_ptr[0]); + if (cnt >= NUM_LEADING_ZEROS) + { + res_ptr[N - 1] = res_ptr[0] << (cnt - NUM_LEADING_ZEROS); + res_ptr[0] = 0; + } + else + { + res_ptr[N - 1] = res_ptr[0] >> (NUM_LEADING_ZEROS - cnt); + res_ptr[0] <<= BITS_PER_MP_LIMB - (NUM_LEADING_ZEROS - cnt); + } + *expt = LDBL_MIN_EXP - 1 + - (BITS_PER_MP_LIMB - NUM_LEADING_ZEROS) - cnt; + } +#else + int j, k, l; + + for (j = N - 1; j > 0; j--) + if (res_ptr[j] != 0) + break; + + count_leading_zeros (cnt, res_ptr[j]); + cnt -= NUM_LEADING_ZEROS; + l = N - 1 - j; + if (cnt < 0) + { + cnt += BITS_PER_MP_LIMB; + l--; + } + if (!cnt) + for (k = N - 1; k >= l; k--) + res_ptr[k] = res_ptr[k-l]; + else + { + for (k = N - 1; k > l; k--) + res_ptr[k] = res_ptr[k-l] << cnt + | res_ptr[k-l-1] >> (BITS_PER_MP_LIMB - cnt); + res_ptr[k--] = res_ptr[0] << cnt; + } + + for (; k >= 0; k--) + res_ptr[k] = 0; + *expt = LDBL_MIN_EXP - 1 - l * BITS_PER_MP_LIMB - cnt; +#endif + } + } + else + /* Add the implicit leading one bit for a normalized number. */ + res_ptr[N - 1] |= (mp_limb_t) 1 << (LDBL_MANT_DIG - 1 + - ((N - 1) * BITS_PER_MP_LIMB)); + + return N; +} diff --git a/sysdeps/ieee754/ldbl-128ibm/math_ldbl.h b/sysdeps/ieee754/ldbl-128ibm/math_ldbl.h new file mode 100644 index 0000000..e7e1b96 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/math_ldbl.h @@ -0,0 +1,124 @@ +#ifndef _MATH_PRIVATE_H_ +#error "Never use directly; include instead." +#endif + +#include + +#define EXTRACT_IBM_EXTENDED_MANTISSA(hi64, lo64, expnt, ibm_ext_ldbl) \ + do \ + { \ + /* We have 105 bits of mantissa plus one implicit digit. Since \ + 106 bits are representable without the rest using hexadecimal \ + digits we use only the implicit digits for the number before \ + the decimal point. */ \ + unsigned long long hi, lo; \ + int ediff; \ + union ibm_extended_long_double eldbl; \ + eldbl.d = ibm_ext_ldbl; \ + expnt = eldbl.ieee.exponent - IBM_EXTENDED_LONG_DOUBLE_BIAS; \ + \ + lo = ((long long)eldbl.ieee.mantissa2 << 32) | eldbl.ieee.mantissa3; \ + hi = ((long long)eldbl.ieee.mantissa0 << 32) | eldbl.ieee.mantissa1; \ + /* If the lower double is not a denomal or zero then set the hidden \ + 53rd bit. */ \ + if (eldbl.ieee.exponent2 > 0x001) \ + { \ + lo |= (1ULL << 52); \ + lo = lo << 7; /* pre-shift lo to match ieee854. */ \ + /* The lower double is normalized separately from the upper. We \ + may need to adjust the lower manitissa to reflect this. */ \ + ediff = eldbl.ieee.exponent - eldbl.ieee.exponent2; \ + if (ediff > 53) \ + lo = lo >> (ediff-53); \ + } \ + hi |= (1ULL << 52); \ + \ + if ((eldbl.ieee.negative != eldbl.ieee.negative2) \ + && ((eldbl.ieee.exponent2 != 0) && (lo != 0LL))) \ + { \ + hi--; \ + lo = (1ULL << 60) - lo; \ + if (hi < (1ULL << 52)) \ + { \ + /* we have a borrow from the hidden bit, so shift left 1. */ \ + hi = (hi << 1) | (lo >> 59); \ + lo = 0xfffffffffffffffLL & (lo << 1); \ + expnt--; \ + } \ + } \ + lo64 = (hi << 60) | lo; \ + hi64 = hi >> 4; \ + } \ + while (0) + +#define INSERT_IBM_EXTENDED_MANTISSA(ibm_ext_ldbl, sign, expnt, hi64, lo64) \ + do \ + { \ + union ibm_extended_long_double u; \ + unsigned long hidden2, lzcount; \ + unsigned long long hi, lo; \ + \ + u.ieee.negative = sign; \ + u.ieee.negative2 = sign; \ + u.ieee.exponent = expnt + IBM_EXTENDED_LONG_DOUBLE_BIAS; \ + u.ieee.exponent2 = expnt-53 + IBM_EXTENDED_LONG_DOUBLE_BIAS; \ + /* Expect 113 bits (112 bits + hidden) right justified in two longs. \ + The low order 53 bits (52 + hidden) go into the lower double */ \ + lo = (lo64 >> 7)& ((1ULL << 53) - 1); \ + hidden2 = (lo64 >> 59) & 1ULL; \ + /* The high order 53 bits (52 + hidden) go into the upper double */ \ + hi = (lo64 >> 60) & ((1ULL << 11) - 1); \ + hi |= (hi64 << 4); \ + \ + if (lo != 0LL) \ + { \ + /* hidden2 bit of low double controls rounding of the high double. \ + If hidden2 is '1' then round up hi and adjust lo (2nd mantissa) \ + plus change the sign of the low double to compensate. */ \ + if (hidden2) \ + { \ + hi++; \ + u.ieee.negative2 = !sign; \ + lo = (1ULL << 53) - lo; \ + } \ + /* The hidden bit of the lo mantissa is zero so we need to \ + normalize the it for the low double. Shift it left until the \ + hidden bit is '1' then adjust the 2nd exponent accordingly. */ \ + \ + if (sizeof (lo) == sizeof (long)) \ + lzcount = __builtin_clzl (lo); \ + else if ((lo >> 32) != 0) \ + lzcount = __builtin_clzl ((long) (lo >> 32)); \ + else \ + lzcount = __builtin_clzl ((long) lo) + 32; \ + lzcount = lzcount - 11; \ + if (lzcount > 0) \ + { \ + int expnt2 = u.ieee.exponent2 - lzcount; \ + if (expnt2 >= 1) \ + { \ + /* Not denormal. Normalize and set low exponent. */ \ + lo = lo << lzcount; \ + u.ieee.exponent2 = expnt2; \ + } \ + else \ + { \ + /* Is denormal. */ \ + lo = lo << (lzcount + expnt2); \ + u.ieee.exponent2 = 0; \ + } \ + } \ + } \ + else \ + { \ + u.ieee.negative2 = 0; \ + u.ieee.exponent2 = 0; \ + } \ + \ + u.ieee.mantissa3 = lo & ((1ULL << 32) - 1); \ + u.ieee.mantissa2 = (lo >> 32) & ((1ULL << 20) - 1); \ + u.ieee.mantissa1 = hi & ((1ULL << 32) - 1); \ + u.ieee.mantissa0 = (hi >> 32) & ((1ULL << 20) - 1); \ + ibm_ext_ldbl = u.d; \ + } \ + while (0) diff --git a/sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c b/sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c new file mode 100644 index 0000000..8a2d45e --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c @@ -0,0 +1,103 @@ +/* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2002, 2003, 2004, 2006 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include "gmp.h" +#include "gmp-impl.h" +#include +#include +#include + +/* Convert a multi-precision integer of the needed number of bits (106 + for long double) and an integral power of two to a `long double' in + IBM extended format. */ + +long double +__mpn_construct_long_double (mp_srcptr frac_ptr, int expt, int sign) +{ + union ibm_extended_long_double u; + unsigned long hidden2, lzcount; + unsigned long long hi, lo; + + u.ieee.negative = sign; + u.ieee.negative2 = sign; + u.ieee.exponent = expt + IBM_EXTENDED_LONG_DOUBLE_BIAS; + u.ieee.exponent2 = expt - 53 + IBM_EXTENDED_LONG_DOUBLE_BIAS; + +#if BITS_PER_MP_LIMB == 32 + /* The low order 53 bits (52 + hidden) go into the lower double */ + lo = frac_ptr[0]; + lo |= (frac_ptr[1] & ((1LL << (53 - 32)) - 1)) << 32; + hidden2 = (frac_ptr[1] >> (52 - 32)) & ((mp_limb_t) 1); + /* The high order 53 bits (52 + hidden) go into the upper double */ + hi = (frac_ptr[1] >> (53 - 32)) & ((1 << 11) - 1); + hi |= ((unsigned long long) frac_ptr[2]) << 11; + hi |= ((unsigned long long) frac_ptr[3]) << (32 + 11); +#elif BITS_PER_MP_LIMB == 64 + /* The low order 53 bits (52 + hidden) go into the lower double */ + lo = frac_ptr[0] & (((mp_limb_t) 1 << 53) - 1); + hidden2 = (frac_ptr[0] >> 52) & ((mp_limb_t) 1); + /* The high order 53 bits (52 + hidden) go into the upper double */ + hi = (frac_ptr[0] >> 53) & (((mp_limb_t) 1 << 11) - 1); + hi |= (frac_ptr[1] << 11); +#else + #error "mp_limb size " BITS_PER_MP_LIMB "not accounted for" +#endif + + if (lo != 0L) + { + /* hidden2 bit of low double controls rounding of the high double. + If hidden2 is '1' then round up hi and adjust lo (2nd mantissa) + plus change the sign of the low double to compensate. */ + if (hidden2) + { + hi++; + u.ieee.negative2 = !sign; + lo = (1LL << 53) - lo; + } + + /* The hidden bit of the lo mantissa is zero so we need to normalize + it for the low double. Shift it left until the hidden bit is '1' + then adjust the 2nd exponent accordingly. */ + + if (sizeof (lo) == sizeof (long)) + lzcount = __builtin_clzl (lo); + else if ((lo >> 32) != 0) + lzcount = __builtin_clzl ((long) (lo >> 32)); + else + lzcount = __builtin_clzl ((long) lo) + 32; + lzcount = lzcount - 11; + if (lzcount > 0) + { + lo = lo << lzcount; + u.ieee.exponent2 = u.ieee.exponent2 - lzcount; + } + } + else + { + u.ieee.negative2 = 0; + u.ieee.exponent2 = 0; + } + + u.ieee.mantissa3 = lo & 0xffffffffLL; + u.ieee.mantissa2 = (lo >> 32) & 0xffffff; + u.ieee.mantissa1 = hi & 0xffffffffLL; + u.ieee.mantissa0 = (hi >> 32) & ((1LL << (LDBL_MANT_DIG - 86)) - 1); + + return u.d; +} diff --git a/sysdeps/ieee754/ldbl-128ibm/printf_fphex.c b/sysdeps/ieee754/ldbl-128ibm/printf_fphex.c new file mode 100644 index 0000000..2a7b70f --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/printf_fphex.c @@ -0,0 +1,138 @@ +/* Print floating point number in hexadecimal notation according to ISO C99. + Copyright (C) 1997,1998,1999,2000,2001,2002,2004,2006 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#define PRINT_FPHEX_LONG_DOUBLE \ +do { \ + /* We have 105 bits of mantissa plus one implicit digit. Since \ + 106 bits are representable without rest using hexadecimal \ + digits we use only the implicit digits for the number before \ + the decimal point. */ \ + unsigned long long int num0, num1; \ + unsigned long long hi, lo; \ + int ediff; \ + union ibm_extended_long_double eldbl; \ + eldbl.d = fpnum.ldbl.d; \ + \ + assert (sizeof (long double) == 16); \ + \ + lo = ((long long)eldbl.ieee.mantissa2 << 32) | eldbl.ieee.mantissa3; \ + hi = ((long long)eldbl.ieee.mantissa0 << 32) | eldbl.ieee.mantissa1; \ + /* If the lower double is not a denomal or zero then set the hidden \ + 53rd bit. */ \ + if (eldbl.ieee.exponent2 > 0x001) \ + { \ + lo |= (1ULL << 52); \ + lo = lo << 7; /* pre-shift lo to match ieee854. */ \ + /* The lower double is normalized separately from the upper. We \ + may need to adjust the lower manitissa to reflect this. */ \ + ediff = eldbl.ieee.exponent - eldbl.ieee.exponent2; \ + if (ediff > 53) \ + lo = lo >> (ediff-53); \ + } \ + \ + if ((eldbl.ieee.negative != eldbl.ieee.negative2) \ + && ((eldbl.ieee.exponent2 != 0) && (lo != 0L))) \ + { \ + lo = (1ULL << 60) - lo; \ + if (hi == 0L) \ + { \ + /* we have a borrow from the hidden bit, so shift left 1. */ \ + hi = 0xffffffffffffeLL | (lo >> 59); \ + lo = 0xfffffffffffffffLL & (lo << 1); \ + eldbl.ieee.exponent--; \ + } \ + else \ + hi--; \ + } \ + num1 = (hi << 60) | lo; \ + num0 = hi >> 4; \ + \ + zero_mantissa = (num0|num1) == 0; \ + \ + if (sizeof (unsigned long int) > 6) \ + { \ + numstr = _itoa_word (num1, numbuf + sizeof numbuf, 16, \ + info->spec == 'A'); \ + wnumstr = _itowa_word (num1, \ + wnumbuf + sizeof (wnumbuf) / sizeof (wchar_t),\ + 16, info->spec == 'A'); \ + } \ + else \ + { \ + numstr = _itoa (num1, numbuf + sizeof numbuf, 16, \ + info->spec == 'A'); \ + wnumstr = _itowa (num1, \ + wnumbuf + sizeof (wnumbuf) / sizeof (wchar_t), \ + 16, info->spec == 'A'); \ + } \ + \ + while (numstr > numbuf + (sizeof numbuf - 64 / 4)) \ + { \ + *--numstr = '0'; \ + *--wnumstr = L'0'; \ + } \ + \ + if (sizeof (unsigned long int) > 6) \ + { \ + numstr = _itoa_word (num0, numstr, 16, info->spec == 'A'); \ + wnumstr = _itowa_word (num0, wnumstr, 16, info->spec == 'A'); \ + } \ + else \ + { \ + numstr = _itoa (num0, numstr, 16, info->spec == 'A'); \ + wnumstr = _itowa (num0, wnumstr, 16, info->spec == 'A'); \ + } \ + \ + /* Fill with zeroes. */ \ + while (numstr > numbuf + (sizeof numbuf - 112 / 4)) \ + { \ + *--numstr = '0'; \ + *--wnumstr = L'0'; \ + } \ + \ + leading = eldbl.ieee.exponent == 0 ? '0' : '1'; \ + \ + exponent = eldbl.ieee.exponent; \ + \ + if (exponent == 0) \ + { \ + if (zero_mantissa) \ + expnegative = 0; \ + else \ + { \ + /* This is a denormalized number. */ \ + expnegative = 1; \ + exponent = IBM_EXTENDED_LONG_DOUBLE_BIAS - 1; \ + } \ + } \ + else if (exponent >= IBM_EXTENDED_LONG_DOUBLE_BIAS) \ + { \ + expnegative = 0; \ + exponent -= IBM_EXTENDED_LONG_DOUBLE_BIAS; \ + } \ + else \ + { \ + expnegative = 1; \ + exponent = -(exponent - IBM_EXTENDED_LONG_DOUBLE_BIAS); \ + } \ +} while (0) + +#include diff --git a/sysdeps/ieee754/ldbl-128ibm/s_asinhl.c b/sysdeps/ieee754/ldbl-128ibm/s_asinhl.c new file mode 100644 index 0000000..d1b63bb --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_asinhl.c @@ -0,0 +1,67 @@ +/* @(#)s_asinh.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: s_asinh.c,v 1.9 1995/05/12 04:57:37 jtc Exp $"; +#endif + +/* asinh(x) + * Method : + * Based on + * asinh(x) = sign(x) * log [ |x| + sqrt(x*x+1) ] + * we have + * asinh(x) := x if 1+x*x=1, + * := sign(x)*(log(x)+ln2)) for large |x|, else + * := sign(x)*log(2|x|+1/(|x|+sqrt(x*x+1))) if|x|>2, else + * := sign(x)*log1p(|x| + x^2/(1 + sqrt(1+x^2))) + */ + +#include "math.h" +#include "math_private.h" +#include + +#ifdef __STDC__ +static const long double +#else +static long double +#endif +one = 1.00000000000000000000e+00L, /* 0x3ff0000000000000, 0 */ +ln2 = 0.6931471805599453094172321214581766L, /* 0x3fe62e42fefa39ef, 0x3c7abc9e3b398040 */ +huge= 1.00000000000000000000e+300L; + +#ifdef __STDC__ + long double __asinhl(long double x) +#else + long double __asinhl(x) + long double x; +#endif +{ + long double t,w; + int64_t hx,ix; + GET_LDOUBLE_MSW64(hx,x); + ix = hx&0x7fffffffffffffffLL; + if(ix>=0x7ff0000000000000LL) return x+x; /* x is inf or NaN */ + if(ix< 0x3e20000000000000LL) { /* |x|<2**-29 */ + if(huge+x>one) return x; /* return x inexact except 0 */ + } + if(ix>0x41b0000000000000LL) { /* |x| > 2**28 */ + w = __ieee754_logl(fabs(x))+ln2; + } else if (ix>0x4000000000000000LL) { /* 2**28 > |x| > 2.0 */ + t = fabs(x); + w = __ieee754_logl(2.0*t+one/(__ieee754_sqrtl(x*x+one)+t)); + } else { /* 2.0 > |x| > 2**-29 */ + t = x*x; + w =__log1pl(fabsl(x)+t/(one+__ieee754_sqrtl(one+t))); + } + if(hx>0) return w; else return -w; +} +long_double_symbol (libm, __asinhl, asinhl); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_atanl.c b/sysdeps/ieee754/ldbl-128ibm/s_atanl.c new file mode 100644 index 0000000..b6195f1 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_atanl.c @@ -0,0 +1,234 @@ +/* s_atanl.c + * + * Inverse circular tangent for 128-bit long double precision + * (arctangent) + * + * + * + * SYNOPSIS: + * + * long double x, y, atanl(); + * + * y = atanl( x ); + * + * + * + * DESCRIPTION: + * + * Returns radian angle between -pi/2 and +pi/2 whose tangent is x. + * + * The function uses a rational approximation of the form + * t + t^3 P(t^2)/Q(t^2), optimized for |t| < 0.09375. + * + * The argument is reduced using the identity + * arctan x - arctan u = arctan ((x-u)/(1 + ux)) + * and an 83-entry lookup table for arctan u, with u = 0, 1/8, ..., 10.25. + * Use of the table improves the execution speed of the routine. + * + * + * + * ACCURACY: + * + * Relative error: + * arithmetic domain # trials peak rms + * IEEE -19, 19 4e5 1.7e-34 5.4e-35 + * + * + * WARNING: + * + * This program uses integer operations on bit fields of floating-point + * numbers. It does not work with data structures other than the + * structure assumed. + * + */ + +/* Copyright 2001 by Stephen L. Moshier + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + + +#include "math_private.h" +#include + +/* arctan(k/8), k = 0, ..., 82 */ +static const long double atantbl[84] = { + 0.0000000000000000000000000000000000000000E0L, + 1.2435499454676143503135484916387102557317E-1L, /* arctan(0.125) */ + 2.4497866312686415417208248121127581091414E-1L, + 3.5877067027057222039592006392646049977698E-1L, + 4.6364760900080611621425623146121440202854E-1L, + 5.5859931534356243597150821640166127034645E-1L, + 6.4350110879328438680280922871732263804151E-1L, + 7.1882999962162450541701415152590465395142E-1L, + 7.8539816339744830961566084581987572104929E-1L, + 8.4415398611317100251784414827164750652594E-1L, + 8.9605538457134395617480071802993782702458E-1L, + 9.4200004037946366473793717053459358607166E-1L, + 9.8279372324732906798571061101466601449688E-1L, + 1.0191413442663497346383429170230636487744E0L, + 1.0516502125483736674598673120862998296302E0L, + 1.0808390005411683108871567292171998202703E0L, + 1.1071487177940905030170654601785370400700E0L, + 1.1309537439791604464709335155363278047493E0L, + 1.1525719972156675180401498626127513797495E0L, + 1.1722738811284763866005949441337046149712E0L, + 1.1902899496825317329277337748293183376012E0L, + 1.2068173702852525303955115800565576303133E0L, + 1.2220253232109896370417417439225704908830E0L, + 1.2360594894780819419094519711090786987027E0L, + 1.2490457723982544258299170772810901230778E0L, + 1.2610933822524404193139408812473357720101E0L, + 1.2722973952087173412961937498224804940684E0L, + 1.2827408797442707473628852511364955306249E0L, + 1.2924966677897852679030914214070816845853E0L, + 1.3016288340091961438047858503666855921414E0L, + 1.3101939350475556342564376891719053122733E0L, + 1.3182420510168370498593302023271362531155E0L, + 1.3258176636680324650592392104284756311844E0L, + 1.3329603993374458675538498697331558093700E0L, + 1.3397056595989995393283037525895557411039E0L, + 1.3460851583802539310489409282517796256512E0L, + 1.3521273809209546571891479413898128509842E0L, + 1.3578579772154994751124898859640585287459E0L, + 1.3633001003596939542892985278250991189943E0L, + 1.3684746984165928776366381936948529556191E0L, + 1.3734007669450158608612719264449611486510E0L, + 1.3780955681325110444536609641291551522494E0L, + 1.3825748214901258580599674177685685125566E0L, + 1.3868528702577214543289381097042486034883E0L, + 1.3909428270024183486427686943836432060856E0L, + 1.3948567013423687823948122092044222644895E0L, + 1.3986055122719575950126700816114282335732E0L, + 1.4021993871854670105330304794336492676944E0L, + 1.4056476493802697809521934019958079881002E0L, + 1.4089588955564736949699075250792569287156E0L, + 1.4121410646084952153676136718584891599630E0L, + 1.4152014988178669079462550975833894394929E0L, + 1.4181469983996314594038603039700989523716E0L, + 1.4209838702219992566633046424614466661176E0L, + 1.4237179714064941189018190466107297503086E0L, + 1.4263547484202526397918060597281265695725E0L, + 1.4288992721907326964184700745371983590908E0L, + 1.4313562697035588982240194668401779312122E0L, + 1.4337301524847089866404719096698873648610E0L, + 1.4360250423171655234964275337155008780675E0L, + 1.4382447944982225979614042479354815855386E0L, + 1.4403930189057632173997301031392126865694E0L, + 1.4424730991091018200252920599377292525125E0L, + 1.4444882097316563655148453598508037025938E0L, + 1.4464413322481351841999668424758804165254E0L, + 1.4483352693775551917970437843145232637695E0L, + 1.4501726582147939000905940595923466567576E0L, + 1.4519559822271314199339700039142990228105E0L, + 1.4536875822280323362423034480994649820285E0L, + 1.4553696664279718992423082296859928222270E0L, + 1.4570043196511885530074841089245667532358E0L, + 1.4585935117976422128825857356750737658039E0L, + 1.4601391056210009726721818194296893361233E0L, + 1.4616428638860188872060496086383008594310E0L, + 1.4631064559620759326975975316301202111560E0L, + 1.4645314639038178118428450961503371619177E0L, + 1.4659193880646627234129855241049975398470E0L, + 1.4672716522843522691530527207287398276197E0L, + 1.4685896086876430842559640450619880951144E0L, + 1.4698745421276027686510391411132998919794E0L, + 1.4711276743037345918528755717617308518553E0L, + 1.4723501675822635384916444186631899205983E0L, + 1.4735431285433308455179928682541563973416E0L, /* arctan(10.25) */ + 1.5707963267948966192313216916397514420986E0L /* pi/2 */ +}; + + +/* arctan t = t + t^3 p(t^2) / q(t^2) + |t| <= 0.09375 + peak relative error 5.3e-37 */ + +static const long double + p0 = -4.283708356338736809269381409828726405572E1L, + p1 = -8.636132499244548540964557273544599863825E1L, + p2 = -5.713554848244551350855604111031839613216E1L, + p3 = -1.371405711877433266573835355036413750118E1L, + p4 = -8.638214309119210906997318946650189640184E-1L, + q0 = 1.285112506901621042780814422948906537959E2L, + q1 = 3.361907253914337187957855834229672347089E2L, + q2 = 3.180448303864130128268191635189365331680E2L, + q3 = 1.307244136980865800160844625025280344686E2L, + q4 = 2.173623741810414221251136181221172551416E1L; + /* q5 = 1.000000000000000000000000000000000000000E0 */ + + +long double +__atanl (long double x) +{ + int k, sign; + long double t, u, p, q; + ieee854_long_double_shape_type s; + + s.value = x; + k = s.parts32.w0; + if (k & 0x80000000) + sign = 1; + else + sign = 0; + + /* Check for IEEE special cases. */ + k &= 0x7fffffff; + if (k >= 0x7ff00000) + { + /* NaN. */ + if ((k & 0xfffff) | s.parts32.w1 ) + return (x + x); + + /* Infinity. */ + if (sign) + return -atantbl[83]; + else + return atantbl[83]; + } + + if (sign) + x = -x; + + if (k >= 0x40248000) /* 10.25 */ + { + k = 83; + t = -1.0/x; + } + else + { + /* Index of nearest table element. + Roundoff to integer is asymmetrical to avoid cancellation when t < 0 + (cf. fdlibm). */ + k = 8.0 * x + 0.25; + u = 0.125 * k; + /* Small arctan argument. */ + t = (x - u) / (1.0 + x * u); + } + + /* Arctan of small argument t. */ + u = t * t; + p = ((((p4 * u) + p3) * u + p2) * u + p1) * u + p0; + q = ((((u + q4) * u + q3) * u + q2) * u + q1) * u + q0; + u = t * u * p / q + t; + + /* arctan x = arctan u + arctan t */ + u = atantbl[k] + u; + if (sign) + return (-u); + else + return u; +} + +long_double_symbol (libm, __atanl, atanl); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_cbrtl.c b/sysdeps/ieee754/ldbl-128ibm/s_cbrtl.c new file mode 100644 index 0000000..010a671 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_cbrtl.c @@ -0,0 +1,6 @@ +/* Looks like we can use ieee854 s_cbrtl.c as is for IBM extended format. */ +#include +#undef weak_alias +#define weak_alias(n,a) +#include +long_double_symbol (libm, __cbrtl, cbrtl); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_ceill.c b/sysdeps/ieee754/ldbl-128ibm/s_ceill.c new file mode 100644 index 0000000..a4cbbe1 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_ceill.c @@ -0,0 +1,119 @@ +/* Ceil (round to +inf) long double floating-point values. + IBM extended format long double version. + Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* This has been coded in assembler because GCC makes such a mess of it + when it's coded in C. */ + +#include +#include +#include +#include +#include + + +#ifdef __STDC__ +long double +__ceill (long double x) +#else +long double +__ceill (x) + long double x; +#endif +{ + static const double TWO52 = 4503599627370496.0L; + int mode = fegetround(); + union ibm_extended_long_double u; + + u.d = x; + + if (fabs (u.dd[0]) < TWO52) + { + fesetround(FE_UPWARD); + if (u.dd[0] > 0.0) + { + u.dd[0] += TWO52; + u.dd[0] -= TWO52; + } + else if (u.dd[0] < 0.0) + { + u.dd[0] -= TWO52; + u.dd[0] += TWO52; + } + u.dd[1] = 0.0; + fesetround(mode); + } + else if (fabs (u.dd[1]) < TWO52 && u.dd[1] != 0.0) + { + double high, low; + /* In this case we have to round the low double and handle any + adjustment to the high double that may be caused by rounding + (up). This is complicated by the fact that the high double + may already be rounded and the low double may have the + opposite sign to compensate. */ + if (u.dd[0] > 0.0) + { + if (u.dd[1] > 0.0) + { + /* If the high/low doubles are the same sign then simply + round the low double. */ + high = u.dd[0]; + low = u.dd[1]; + } + else if (u.dd[1] < 0.0) + { + /* Else the high double is pre rounded and we need to + adjust for that. */ + high = nextafter (u.dd[0], 0.0); + low = u.dd[1] + (u.dd[0] - high); + } + fesetround(FE_UPWARD); + low += TWO52; + low -= TWO52; + fesetround(mode); + } + else if (u.dd[0] < 0.0) + { + if (u.dd[1] < 0.0) + { + /* If the high/low doubles are the same sign then simply + round the low double. */ + high = u.dd[0]; + low = u.dd[1]; + } + else if (u.dd[1] > 0.0) + { + /* Else the high double is pre rounded and we need to + adjust for that. */ + high = nextafter (u.dd[0], 0.0); + low = u.dd[1] + (u.dd[0] - high); + } + fesetround(FE_UPWARD); + low -= TWO52; + low += TWO52; + fesetround(mode); + } + u.dd[0] = high + low; + u.dd[1] = high - u.dd[0] + low; + } + + return u.d; +} + +long_double_symbol (libm, __ceill, ceill); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_copysignl.c b/sysdeps/ieee754/ldbl-128ibm/s_copysignl.c new file mode 100644 index 0000000..7e7b441 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_copysignl.c @@ -0,0 +1,45 @@ +/* s_copysignl.c -- long double version of s_copysign.c. + * Conversion to long double by Jakub Jelinek, jj@ultra.linux.cz. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * copysignl(long double x, long double y) + * copysignl(x,y) returns a value with the magnitude of x and + * with the sign bit of y. + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + long double __copysignl(long double x, long double y) +#else + long double __copysignl(x,y) + long double x,y; +#endif +{ + if (y < 0.0) + { + if (x >= 0.0) + x = -x; + } + else if (x < 0.0) + x = -x; + return x; +} +weak_alias (__copysignl, copysignl) diff --git a/sysdeps/ieee754/ldbl-128ibm/s_cosl.c b/sysdeps/ieee754/ldbl-128ibm/s_cosl.c new file mode 100644 index 0000000..59a8196 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_cosl.c @@ -0,0 +1,88 @@ +/* s_cosl.c -- long double version of s_cos.c. + * Conversion to long double by Jakub Jelinek, jj@ultra.linux.cz. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* cosl(x) + * Return cosine function of x. + * + * kernel function: + * __kernel_sinl ... sine function on [-pi/4,pi/4] + * __kernel_cosl ... cosine function on [-pi/4,pi/4] + * __ieee754_rem_pio2l ... argument reduction routine + * + * Method. + * Let S,C and T denote the sin, cos and tan respectively on + * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 + * in [-pi/4 , +pi/4], and let n = k mod 4. + * We have + * + * n sin(x) cos(x) tan(x) + * ---------------------------------------------------------- + * 0 S C T + * 1 C -S -1/T + * 2 -S -C T + * 3 -C S -1/T + * ---------------------------------------------------------- + * + * Special cases: + * Let trig be any of sin, cos, or tan. + * trig(+-INF) is NaN, with signals; + * trig(NaN) is that NaN; + * + * Accuracy: + * TRIG(x) returns trig(x) nearly rounded + */ + +#include "math.h" +#include "math_private.h" +#include + +#ifdef __STDC__ + long double __cosl(long double x) +#else + long double __cosl(x) + long double x; +#endif +{ + long double y[2],z=0.0L; + int64_t n, ix; + + /* High word of x. */ + GET_LDOUBLE_MSW64(ix,x); + + /* |x| ~< pi/4 */ + ix &= 0x7fffffffffffffffLL; + if(ix <= 0x3fe921fb54442d18LL) + return __kernel_cosl(x,z); + + /* cos(Inf or NaN) is NaN */ + else if (ix>=0x7ff0000000000000LL) + return x-x; + + /* argument reduction needed */ + else { + n = __ieee754_rem_pio2l(x,y); + switch(n&3) { + case 0: + return __kernel_cosl(y[0],y[1]); + case 1: + return -__kernel_sinl(y[0],y[1],1); + case 2: + return -__kernel_cosl(y[0],y[1]); + default: + return __kernel_sinl(y[0],y[1],1); + } + } +} +long_double_symbol (libm, __cosl, cosl); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_erfl.c b/sysdeps/ieee754/ldbl-128ibm/s_erfl.c new file mode 100644 index 0000000..02b450e --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_erfl.c @@ -0,0 +1,958 @@ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* Modifications and expansions for 128-bit long double are + Copyright (C) 2001 Stephen L. Moshier + and are incorporated herein by permission of the author. The author + reserves the right to distribute this material elsewhere under different + copying permissions. These modifications are distributed here under + the following terms: + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* double erf(double x) + * double erfc(double x) + * x + * 2 |\ + * erf(x) = --------- | exp(-t*t)dt + * sqrt(pi) \| + * 0 + * + * erfc(x) = 1-erf(x) + * Note that + * erf(-x) = -erf(x) + * erfc(-x) = 2 - erfc(x) + * + * Method: + * 1. erf(x) = x + x*R(x^2) for |x| in [0, 7/8] + * Remark. The formula is derived by noting + * erf(x) = (2/sqrt(pi))*(x - x^3/3 + x^5/10 - x^7/42 + ....) + * and that + * 2/sqrt(pi) = 1.128379167095512573896158903121545171688 + * is close to one. + * + * 1a. erf(x) = 1 - erfc(x), for |x| > 1.0 + * erfc(x) = 1 - erf(x) if |x| < 1/4 + * + * 2. For |x| in [7/8, 1], let s = |x| - 1, and + * c = 0.84506291151 rounded to single (24 bits) + * erf(s + c) = sign(x) * (c + P1(s)/Q1(s)) + * Remark: here we use the taylor series expansion at x=1. + * erf(1+s) = erf(1) + s*Poly(s) + * = 0.845.. + P1(s)/Q1(s) + * Note that |P1/Q1|< 0.078 for x in [0.84375,1.25] + * + * 3. For x in [1/4, 5/4], + * erfc(s + const) = erfc(const) + s P1(s)/Q1(s) + * for const = 1/4, 3/8, ..., 9/8 + * and 0 <= s <= 1/8 . + * + * 4. For x in [5/4, 107], + * erfc(x) = (1/x)*exp(-x*x-0.5625 + R(z)) + * z=1/x^2 + * The interval is partitioned into several segments + * of width 1/8 in 1/x. + * + * Note1: + * To compute exp(-x*x-0.5625+R/S), let s be a single + * precision number and s := x; then + * -x*x = -s*s + (s-x)*(s+x) + * exp(-x*x-0.5626+R/S) = + * exp(-s*s-0.5625)*exp((s-x)*(s+x)+R/S); + * Note2: + * Here 4 and 5 make use of the asymptotic series + * exp(-x*x) + * erfc(x) ~ ---------- * ( 1 + Poly(1/x^2) ) + * x*sqrt(pi) + * + * 5. For inf > x >= 107 + * erf(x) = sign(x) *(1 - tiny) (raise inexact) + * erfc(x) = tiny*tiny (raise underflow) if x > 0 + * = 2 - tiny if x<0 + * + * 7. Special case: + * erf(0) = 0, erf(inf) = 1, erf(-inf) = -1, + * erfc(0) = 1, erfc(inf) = 0, erfc(-inf) = 2, + * erfc/erf(NaN) is NaN + */ + +#include "math.h" +#include "math_private.h" +#include + +/* Evaluate P[n] x^n + P[n-1] x^(n-1) + ... + P[0] */ + +static long double +neval (long double x, const long double *p, int n) +{ + long double y; + + p += n; + y = *p--; + do + { + y = y * x + *p--; + } + while (--n > 0); + return y; +} + + +/* Evaluate x^n+1 + P[n] x^(n) + P[n-1] x^(n-1) + ... + P[0] */ + +static long double +deval (long double x, const long double *p, int n) +{ + long double y; + + p += n; + y = x + *p--; + do + { + y = y * x + *p--; + } + while (--n > 0); + return y; +} + + + +#ifdef __STDC__ +static const long double +#else +static long double +#endif +tiny = 1e-300L, + half = 0.5L, + one = 1.0L, + two = 2.0L, + /* 2/sqrt(pi) - 1 */ + efx = 1.2837916709551257389615890312154517168810E-1L, + /* 8 * (2/sqrt(pi) - 1) */ + efx8 = 1.0270333367641005911692712249723613735048E0L; + + +/* erf(x) = x + x R(x^2) + 0 <= x <= 7/8 + Peak relative error 1.8e-35 */ +#define NTN1 8 +static const long double TN1[NTN1 + 1] = +{ + -3.858252324254637124543172907442106422373E10L, + 9.580319248590464682316366876952214879858E10L, + 1.302170519734879977595901236693040544854E10L, + 2.922956950426397417800321486727032845006E9L, + 1.764317520783319397868923218385468729799E8L, + 1.573436014601118630105796794840834145120E7L, + 4.028077380105721388745632295157816229289E5L, + 1.644056806467289066852135096352853491530E4L, + 3.390868480059991640235675479463287886081E1L +}; +#define NTD1 8 +static const long double TD1[NTD1 + 1] = +{ + -3.005357030696532927149885530689529032152E11L, + -1.342602283126282827411658673839982164042E11L, + -2.777153893355340961288511024443668743399E10L, + -3.483826391033531996955620074072768276974E9L, + -2.906321047071299585682722511260895227921E8L, + -1.653347985722154162439387878512427542691E7L, + -6.245520581562848778466500301865173123136E5L, + -1.402124304177498828590239373389110545142E4L, + -1.209368072473510674493129989468348633579E2L +/* 1.0E0 */ +}; + + +/* erf(z+1) = erf_const + P(z)/Q(z) + -.125 <= z <= 0 + Peak relative error 7.3e-36 */ +static const long double erf_const = 0.845062911510467529296875L; +#define NTN2 8 +static const long double TN2[NTN2 + 1] = +{ + -4.088889697077485301010486931817357000235E1L, + 7.157046430681808553842307502826960051036E3L, + -2.191561912574409865550015485451373731780E3L, + 2.180174916555316874988981177654057337219E3L, + 2.848578658049670668231333682379720943455E2L, + 1.630362490952512836762810462174798925274E2L, + 6.317712353961866974143739396865293596895E0L, + 2.450441034183492434655586496522857578066E1L, + 5.127662277706787664956025545897050896203E-1L +}; +#define NTD2 8 +static const long double TD2[NTD2 + 1] = +{ + 1.731026445926834008273768924015161048885E4L, + 1.209682239007990370796112604286048173750E4L, + 1.160950290217993641320602282462976163857E4L, + 5.394294645127126577825507169061355698157E3L, + 2.791239340533632669442158497532521776093E3L, + 8.989365571337319032943005387378993827684E2L, + 2.974016493766349409725385710897298069677E2L, + 6.148192754590376378740261072533527271947E1L, + 1.178502892490738445655468927408440847480E1L + /* 1.0E0 */ +}; + + +/* erfc(x + 0.25) = erfc(0.25) + x R(x) + 0 <= x < 0.125 + Peak relative error 1.4e-35 */ +#define NRNr13 8 +static const long double RNr13[NRNr13 + 1] = +{ + -2.353707097641280550282633036456457014829E3L, + 3.871159656228743599994116143079870279866E2L, + -3.888105134258266192210485617504098426679E2L, + -2.129998539120061668038806696199343094971E1L, + -8.125462263594034672468446317145384108734E1L, + 8.151549093983505810118308635926270319660E0L, + -5.033362032729207310462422357772568553670E0L, + -4.253956621135136090295893547735851168471E-2L, + -8.098602878463854789780108161581050357814E-2L +}; +#define NRDr13 7 +static const long double RDr13[NRDr13 + 1] = +{ + 2.220448796306693503549505450626652881752E3L, + 1.899133258779578688791041599040951431383E2L, + 1.061906712284961110196427571557149268454E3L, + 7.497086072306967965180978101974566760042E1L, + 2.146796115662672795876463568170441327274E2L, + 1.120156008362573736664338015952284925592E1L, + 2.211014952075052616409845051695042741074E1L, + 6.469655675326150785692908453094054988938E-1L + /* 1.0E0 */ +}; +/* erfc(0.25) = C13a + C13b to extra precision. */ +static const long double C13a = 0.723663330078125L; +static const long double C13b = 1.0279753638067014931732235184287934646022E-5L; + + +/* erfc(x + 0.375) = erfc(0.375) + x R(x) + 0 <= x < 0.125 + Peak relative error 1.2e-35 */ +#define NRNr14 8 +static const long double RNr14[NRNr14 + 1] = +{ + -2.446164016404426277577283038988918202456E3L, + 6.718753324496563913392217011618096698140E2L, + -4.581631138049836157425391886957389240794E2L, + -2.382844088987092233033215402335026078208E1L, + -7.119237852400600507927038680970936336458E1L, + 1.313609646108420136332418282286454287146E1L, + -6.188608702082264389155862490056401365834E0L, + -2.787116601106678287277373011101132659279E-2L, + -2.230395570574153963203348263549700967918E-2L +}; +#define NRDr14 7 +static const long double RDr14[NRDr14 + 1] = +{ + 2.495187439241869732696223349840963702875E3L, + 2.503549449872925580011284635695738412162E2L, + 1.159033560988895481698051531263861842461E3L, + 9.493751466542304491261487998684383688622E1L, + 2.276214929562354328261422263078480321204E2L, + 1.367697521219069280358984081407807931847E1L, + 2.276988395995528495055594829206582732682E1L, + 7.647745753648996559837591812375456641163E-1L + /* 1.0E0 */ +}; +/* erfc(0.375) = C14a + C14b to extra precision. */ +static const long double C14a = 0.5958709716796875L; +static const long double C14b = 1.2118885490201676174914080878232469565953E-5L; + +/* erfc(x + 0.5) = erfc(0.5) + x R(x) + 0 <= x < 0.125 + Peak relative error 4.7e-36 */ +#define NRNr15 8 +static const long double RNr15[NRNr15 + 1] = +{ + -2.624212418011181487924855581955853461925E3L, + 8.473828904647825181073831556439301342756E2L, + -5.286207458628380765099405359607331669027E2L, + -3.895781234155315729088407259045269652318E1L, + -6.200857908065163618041240848728398496256E1L, + 1.469324610346924001393137895116129204737E1L, + -6.961356525370658572800674953305625578903E0L, + 5.145724386641163809595512876629030548495E-3L, + 1.990253655948179713415957791776180406812E-2L +}; +#define NRDr15 7 +static const long double RDr15[NRDr15 + 1] = +{ + 2.986190760847974943034021764693341524962E3L, + 5.288262758961073066335410218650047725985E2L, + 1.363649178071006978355113026427856008978E3L, + 1.921707975649915894241864988942255320833E2L, + 2.588651100651029023069013885900085533226E2L, + 2.628752920321455606558942309396855629459E1L, + 2.455649035885114308978333741080991380610E1L, + 1.378826653595128464383127836412100939126E0L + /* 1.0E0 */ +}; +/* erfc(0.5) = C15a + C15b to extra precision. */ +static const long double C15a = 0.4794921875L; +static const long double C15b = 7.9346869534623172533461080354712635484242E-6L; + +/* erfc(x + 0.625) = erfc(0.625) + x R(x) + 0 <= x < 0.125 + Peak relative error 5.1e-36 */ +#define NRNr16 8 +static const long double RNr16[NRNr16 + 1] = +{ + -2.347887943200680563784690094002722906820E3L, + 8.008590660692105004780722726421020136482E2L, + -5.257363310384119728760181252132311447963E2L, + -4.471737717857801230450290232600243795637E1L, + -4.849540386452573306708795324759300320304E1L, + 1.140885264677134679275986782978655952843E1L, + -6.731591085460269447926746876983786152300E0L, + 1.370831653033047440345050025876085121231E-1L, + 2.022958279982138755020825717073966576670E-2L, +}; +#define NRDr16 7 +static const long double RDr16[NRDr16 + 1] = +{ + 3.075166170024837215399323264868308087281E3L, + 8.730468942160798031608053127270430036627E2L, + 1.458472799166340479742581949088453244767E3L, + 3.230423687568019709453130785873540386217E2L, + 2.804009872719893612081109617983169474655E2L, + 4.465334221323222943418085830026979293091E1L, + 2.612723259683205928103787842214809134746E1L, + 2.341526751185244109722204018543276124997E0L, + /* 1.0E0 */ +}; +/* erfc(0.625) = C16a + C16b to extra precision. */ +static const long double C16a = 0.3767547607421875L; +static const long double C16b = 4.3570693945275513594941232097252997287766E-6L; + +/* erfc(x + 0.75) = erfc(0.75) + x R(x) + 0 <= x < 0.125 + Peak relative error 1.7e-35 */ +#define NRNr17 8 +static const long double RNr17[NRNr17 + 1] = +{ + -1.767068734220277728233364375724380366826E3L, + 6.693746645665242832426891888805363898707E2L, + -4.746224241837275958126060307406616817753E2L, + -2.274160637728782675145666064841883803196E1L, + -3.541232266140939050094370552538987982637E1L, + 6.988950514747052676394491563585179503865E0L, + -5.807687216836540830881352383529281215100E0L, + 3.631915988567346438830283503729569443642E-1L, + -1.488945487149634820537348176770282391202E-2L +}; +#define NRDr17 7 +static const long double RDr17[NRDr17 + 1] = +{ + 2.748457523498150741964464942246913394647E3L, + 1.020213390713477686776037331757871252652E3L, + 1.388857635935432621972601695296561952738E3L, + 3.903363681143817750895999579637315491087E2L, + 2.784568344378139499217928969529219886578E2L, + 5.555800830216764702779238020065345401144E1L, + 2.646215470959050279430447295801291168941E1L, + 2.984905282103517497081766758550112011265E0L, + /* 1.0E0 */ +}; +/* erfc(0.75) = C17a + C17b to extra precision. */ +static const long double C17a = 0.2888336181640625L; +static const long double C17b = 1.0748182422368401062165408589222625794046E-5L; + + +/* erfc(x + 0.875) = erfc(0.875) + x R(x) + 0 <= x < 0.125 + Peak relative error 2.2e-35 */ +#define NRNr18 8 +static const long double RNr18[NRNr18 + 1] = +{ + -1.342044899087593397419622771847219619588E3L, + 6.127221294229172997509252330961641850598E2L, + -4.519821356522291185621206350470820610727E2L, + 1.223275177825128732497510264197915160235E1L, + -2.730789571382971355625020710543532867692E1L, + 4.045181204921538886880171727755445395862E0L, + -4.925146477876592723401384464691452700539E0L, + 5.933878036611279244654299924101068088582E-1L, + -5.557645435858916025452563379795159124753E-2L +}; +#define NRDr18 7 +static const long double RDr18[NRDr18 + 1] = +{ + 2.557518000661700588758505116291983092951E3L, + 1.070171433382888994954602511991940418588E3L, + 1.344842834423493081054489613250688918709E3L, + 4.161144478449381901208660598266288188426E2L, + 2.763670252219855198052378138756906980422E2L, + 5.998153487868943708236273854747564557632E1L, + 2.657695108438628847733050476209037025318E1L, + 3.252140524394421868923289114410336976512E0L, + /* 1.0E0 */ +}; +/* erfc(0.875) = C18a + C18b to extra precision. */ +static const long double C18a = 0.215911865234375L; +static const long double C18b = 1.3073705765341685464282101150637224028267E-5L; + +/* erfc(x + 1.0) = erfc(1.0) + x R(x) + 0 <= x < 0.125 + Peak relative error 1.6e-35 */ +#define NRNr19 8 +static const long double RNr19[NRNr19 + 1] = +{ + -1.139180936454157193495882956565663294826E3L, + 6.134903129086899737514712477207945973616E2L, + -4.628909024715329562325555164720732868263E2L, + 4.165702387210732352564932347500364010833E1L, + -2.286979913515229747204101330405771801610E1L, + 1.870695256449872743066783202326943667722E0L, + -4.177486601273105752879868187237000032364E0L, + 7.533980372789646140112424811291782526263E-1L, + -8.629945436917752003058064731308767664446E-2L +}; +#define NRDr19 7 +static const long double RDr19[NRDr19 + 1] = +{ + 2.744303447981132701432716278363418643778E3L, + 1.266396359526187065222528050591302171471E3L, + 1.466739461422073351497972255511919814273E3L, + 4.868710570759693955597496520298058147162E2L, + 2.993694301559756046478189634131722579643E2L, + 6.868976819510254139741559102693828237440E1L, + 2.801505816247677193480190483913753613630E1L, + 3.604439909194350263552750347742663954481E0L, + /* 1.0E0 */ +}; +/* erfc(1.0) = C19a + C19b to extra precision. */ +static const long double C19a = 0.15728759765625L; +static const long double C19b = 1.1609394035130658779364917390740703933002E-5L; + +/* erfc(x + 1.125) = erfc(1.125) + x R(x) + 0 <= x < 0.125 + Peak relative error 3.6e-36 */ +#define NRNr20 8 +static const long double RNr20[NRNr20 + 1] = +{ + -9.652706916457973956366721379612508047640E2L, + 5.577066396050932776683469951773643880634E2L, + -4.406335508848496713572223098693575485978E2L, + 5.202893466490242733570232680736966655434E1L, + -1.931311847665757913322495948705563937159E1L, + -9.364318268748287664267341457164918090611E-2L, + -3.306390351286352764891355375882586201069E0L, + 7.573806045289044647727613003096916516475E-1L, + -9.611744011489092894027478899545635991213E-2L +}; +#define NRDr20 7 +static const long double RDr20[NRDr20 + 1] = +{ + 3.032829629520142564106649167182428189014E3L, + 1.659648470721967719961167083684972196891E3L, + 1.703545128657284619402511356932569292535E3L, + 6.393465677731598872500200253155257708763E2L, + 3.489131397281030947405287112726059221934E2L, + 8.848641738570783406484348434387611713070E1L, + 3.132269062552392974833215844236160958502E1L, + 4.430131663290563523933419966185230513168E0L + /* 1.0E0 */ +}; +/* erfc(1.125) = C20a + C20b to extra precision. */ +static const long double C20a = 0.111602783203125L; +static const long double C20b = 8.9850951672359304215530728365232161564636E-6L; + +/* erfc(1/x) = 1/x exp (-1/x^2 - 0.5625 + R(1/x^2)) + 7/8 <= 1/x < 1 + Peak relative error 1.4e-35 */ +#define NRNr8 9 +static const long double RNr8[NRNr8 + 1] = +{ + 3.587451489255356250759834295199296936784E1L, + 5.406249749087340431871378009874875889602E2L, + 2.931301290625250886238822286506381194157E3L, + 7.359254185241795584113047248898753470923E3L, + 9.201031849810636104112101947312492532314E3L, + 5.749697096193191467751650366613289284777E3L, + 1.710415234419860825710780802678697889231E3L, + 2.150753982543378580859546706243022719599E2L, + 8.740953582272147335100537849981160931197E0L, + 4.876422978828717219629814794707963640913E-2L +}; +#define NRDr8 8 +static const long double RDr8[NRDr8 + 1] = +{ + 6.358593134096908350929496535931630140282E1L, + 9.900253816552450073757174323424051765523E2L, + 5.642928777856801020545245437089490805186E3L, + 1.524195375199570868195152698617273739609E4L, + 2.113829644500006749947332935305800887345E4L, + 1.526438562626465706267943737310282977138E4L, + 5.561370922149241457131421914140039411782E3L, + 9.394035530179705051609070428036834496942E2L, + 6.147019596150394577984175188032707343615E1L + /* 1.0E0 */ +}; + +/* erfc(1/x) = 1/x exp (-1/x^2 - 0.5625 + R(1/x^2)) + 0.75 <= 1/x <= 0.875 + Peak relative error 2.0e-36 */ +#define NRNr7 9 +static const long double RNr7[NRNr7 + 1] = +{ + 1.686222193385987690785945787708644476545E1L, + 1.178224543567604215602418571310612066594E3L, + 1.764550584290149466653899886088166091093E4L, + 1.073758321890334822002849369898232811561E5L, + 3.132840749205943137619839114451290324371E5L, + 4.607864939974100224615527007793867585915E5L, + 3.389781820105852303125270837910972384510E5L, + 1.174042187110565202875011358512564753399E5L, + 1.660013606011167144046604892622504338313E4L, + 6.700393957480661937695573729183733234400E2L +}; +#define NRDr7 9 +static const long double RDr7[NRDr7 + 1] = +{ +-1.709305024718358874701575813642933561169E3L, +-3.280033887481333199580464617020514788369E4L, +-2.345284228022521885093072363418750835214E5L, +-8.086758123097763971926711729242327554917E5L, +-1.456900414510108718402423999575992450138E6L, +-1.391654264881255068392389037292702041855E6L, +-6.842360801869939983674527468509852583855E5L, +-1.597430214446573566179675395199807533371E5L, +-1.488876130609876681421645314851760773480E4L, +-3.511762950935060301403599443436465645703E2L + /* 1.0E0 */ +}; + +/* erfc(1/x) = 1/x exp(-1/x^2 - 0.5625 + R(1/x^2)) + 5/8 <= 1/x < 3/4 + Peak relative error 1.9e-35 */ +#define NRNr6 9 +static const long double RNr6[NRNr6 + 1] = +{ + 1.642076876176834390623842732352935761108E0L, + 1.207150003611117689000664385596211076662E2L, + 2.119260779316389904742873816462800103939E3L, + 1.562942227734663441801452930916044224174E4L, + 5.656779189549710079988084081145693580479E4L, + 1.052166241021481691922831746350942786299E5L, + 9.949798524786000595621602790068349165758E4L, + 4.491790734080265043407035220188849562856E4L, + 8.377074098301530326270432059434791287601E3L, + 4.506934806567986810091824791963991057083E2L +}; +#define NRDr6 9 +static const long double RDr6[NRDr6 + 1] = +{ +-1.664557643928263091879301304019826629067E2L, +-3.800035902507656624590531122291160668452E3L, +-3.277028191591734928360050685359277076056E4L, +-1.381359471502885446400589109566587443987E5L, +-3.082204287382581873532528989283748656546E5L, +-3.691071488256738343008271448234631037095E5L, +-2.300482443038349815750714219117566715043E5L, +-6.873955300927636236692803579555752171530E4L, +-8.262158817978334142081581542749986845399E3L, +-2.517122254384430859629423488157361983661E2L + /* 1.00 */ +}; + +/* erfc(1/x) = 1/x exp(-1/x^2 - 0.5625 + R(1/x^2)) + 1/2 <= 1/x < 5/8 + Peak relative error 4.6e-36 */ +#define NRNr5 10 +static const long double RNr5[NRNr5 + 1] = +{ +-3.332258927455285458355550878136506961608E-3L, +-2.697100758900280402659586595884478660721E-1L, +-6.083328551139621521416618424949137195536E0L, +-6.119863528983308012970821226810162441263E1L, +-3.176535282475593173248810678636522589861E2L, +-8.933395175080560925809992467187963260693E2L, +-1.360019508488475978060917477620199499560E3L, +-1.075075579828188621541398761300910213280E3L, +-4.017346561586014822824459436695197089916E2L, +-5.857581368145266249509589726077645791341E1L, +-2.077715925587834606379119585995758954399E0L +}; +#define NRDr5 9 +static const long double RDr5[NRDr5 + 1] = +{ + 3.377879570417399341550710467744693125385E-1L, + 1.021963322742390735430008860602594456187E1L, + 1.200847646592942095192766255154827011939E2L, + 7.118915528142927104078182863387116942836E2L, + 2.318159380062066469386544552429625026238E3L, + 4.238729853534009221025582008928765281620E3L, + 4.279114907284825886266493994833515580782E3L, + 2.257277186663261531053293222591851737504E3L, + 5.570475501285054293371908382916063822957E2L, + 5.142189243856288981145786492585432443560E1L + /* 1.0E0 */ +}; + +/* erfc(1/x) = 1/x exp(-1/x^2 - 0.5625 + R(1/x^2)) + 3/8 <= 1/x < 1/2 + Peak relative error 2.0e-36 */ +#define NRNr4 10 +static const long double RNr4[NRNr4 + 1] = +{ + 3.258530712024527835089319075288494524465E-3L, + 2.987056016877277929720231688689431056567E-1L, + 8.738729089340199750734409156830371528862E0L, + 1.207211160148647782396337792426311125923E2L, + 8.997558632489032902250523945248208224445E2L, + 3.798025197699757225978410230530640879762E3L, + 9.113203668683080975637043118209210146846E3L, + 1.203285891339933238608683715194034900149E4L, + 8.100647057919140328536743641735339740855E3L, + 2.383888249907144945837976899822927411769E3L, + 2.127493573166454249221983582495245662319E2L +}; +#define NRDr4 10 +static const long double RDr4[NRDr4 + 1] = +{ +-3.303141981514540274165450687270180479586E-1L, +-1.353768629363605300707949368917687066724E1L, +-2.206127630303621521950193783894598987033E2L, +-1.861800338758066696514480386180875607204E3L, +-8.889048775872605708249140016201753255599E3L, +-2.465888106627948210478692168261494857089E4L, +-3.934642211710774494879042116768390014289E4L, +-3.455077258242252974937480623730228841003E4L, +-1.524083977439690284820586063729912653196E4L, +-2.810541887397984804237552337349093953857E3L, +-1.343929553541159933824901621702567066156E2L + /* 1.0E0 */ +}; + +/* erfc(1/x) = 1/x exp(-1/x^2 - 0.5625 + R(1/x^2)) + 1/4 <= 1/x < 3/8 + Peak relative error 8.4e-37 */ +#define NRNr3 11 +static const long double RNr3[NRNr3 + 1] = +{ +-1.952401126551202208698629992497306292987E-6L, +-2.130881743066372952515162564941682716125E-4L, +-8.376493958090190943737529486107282224387E-3L, +-1.650592646560987700661598877522831234791E-1L, +-1.839290818933317338111364667708678163199E0L, +-1.216278715570882422410442318517814388470E1L, +-4.818759344462360427612133632533779091386E1L, +-1.120994661297476876804405329172164436784E2L, +-1.452850765662319264191141091859300126931E2L, +-9.485207851128957108648038238656777241333E1L, +-2.563663855025796641216191848818620020073E1L, +-1.787995944187565676837847610706317833247E0L +}; +#define NRDr3 10 +static const long double RDr3[NRDr3 + 1] = +{ + 1.979130686770349481460559711878399476903E-4L, + 1.156941716128488266238105813374635099057E-2L, + 2.752657634309886336431266395637285974292E-1L, + 3.482245457248318787349778336603569327521E0L, + 2.569347069372696358578399521203959253162E1L, + 1.142279000180457419740314694631879921561E2L, + 3.056503977190564294341422623108332700840E2L, + 4.780844020923794821656358157128719184422E2L, + 4.105972727212554277496256802312730410518E2L, + 1.724072188063746970865027817017067646246E2L, + 2.815939183464818198705278118326590370435E1L + /* 1.0E0 */ +}; + +/* erfc(1/x) = 1/x exp(-1/x^2 - 0.5625 + R(1/x^2)) + 1/8 <= 1/x < 1/4 + Peak relative error 1.5e-36 */ +#define NRNr2 11 +static const long double RNr2[NRNr2 + 1] = +{ +-2.638914383420287212401687401284326363787E-8L, +-3.479198370260633977258201271399116766619E-6L, +-1.783985295335697686382487087502222519983E-4L, +-4.777876933122576014266349277217559356276E-3L, +-7.450634738987325004070761301045014986520E-2L, +-7.068318854874733315971973707247467326619E-1L, +-4.113919921935944795764071670806867038732E0L, +-1.440447573226906222417767283691888875082E1L, +-2.883484031530718428417168042141288943905E1L, +-2.990886974328476387277797361464279931446E1L, +-1.325283914915104866248279787536128997331E1L, +-1.572436106228070195510230310658206154374E0L +}; +#define NRDr2 10 +static const long double RDr2[NRDr2 + 1] = +{ + 2.675042728136731923554119302571867799673E-6L, + 2.170997868451812708585443282998329996268E-4L, + 7.249969752687540289422684951196241427445E-3L, + 1.302040375859768674620410563307838448508E-1L, + 1.380202483082910888897654537144485285549E0L, + 8.926594113174165352623847870299170069350E0L, + 3.521089584782616472372909095331572607185E1L, + 8.233547427533181375185259050330809105570E1L, + 1.072971579885803033079469639073292840135E2L, + 6.943803113337964469736022094105143158033E1L, + 1.775695341031607738233608307835017282662E1L + /* 1.0E0 */ +}; + +/* erfc(1/x) = 1/x exp(-1/x^2 - 0.5625 + R(1/x^2)) + 1/128 <= 1/x < 1/8 + Peak relative error 2.2e-36 */ +#define NRNr1 9 +static const long double RNr1[NRNr1 + 1] = +{ +-4.250780883202361946697751475473042685782E-8L, +-5.375777053288612282487696975623206383019E-6L, +-2.573645949220896816208565944117382460452E-4L, +-6.199032928113542080263152610799113086319E-3L, +-8.262721198693404060380104048479916247786E-2L, +-6.242615227257324746371284637695778043982E-1L, +-2.609874739199595400225113299437099626386E0L, +-5.581967563336676737146358534602770006970E0L, +-5.124398923356022609707490956634280573882E0L, +-1.290865243944292370661544030414667556649E0L +}; +#define NRDr1 8 +static const long double RDr1[NRDr1 + 1] = +{ + 4.308976661749509034845251315983612976224E-6L, + 3.265390126432780184125233455960049294580E-4L, + 9.811328839187040701901866531796570418691E-3L, + 1.511222515036021033410078631914783519649E-1L, + 1.289264341917429958858379585970225092274E0L, + 6.147640356182230769548007536914983522270E0L, + 1.573966871337739784518246317003956180750E1L, + 1.955534123435095067199574045529218238263E1L, + 9.472613121363135472247929109615785855865E0L + /* 1.0E0 */ +}; + + +#ifdef __STDC__ +long double +__erfl (long double x) +#else +double +__erfl (x) + long double x; +#endif +{ + long double a, y, z; + int32_t i, ix, sign; + ieee854_long_double_shape_type u; + + u.value = x; + sign = u.parts32.w0; + ix = sign & 0x7fffffff; + + if (ix >= 0x7ff00000) + { /* erf(nan)=nan */ + i = ((sign & 0xfff00000) >> 31) << 1; + return (long double) (1 - i) + one / x; /* erf(+-inf)=+-1 */ + } + + if (ix >= 0x3ff00000) /* |x| >= 1.0 */ + { + y = __erfcl (x); + return (one - y); + /* return (one - __erfcl (x)); */ + } + u.parts32.w0 = ix; + a = u.value; + z = x * x; + if (ix < 0x3fec0000) /* a < 0.875 */ + { + if (ix < 0x3c600000) /* |x|<2**-57 */ + { + if (ix < 0x00800000) + { + /* erf (-0) = -0. Unfortunately, for IBM extended double + 0.125 * (8.0 * x + efx8 * x) for x = -0 evaluates to 0. */ + if (x == 0) + return x; + return 0.125 * (8.0 * x + efx8 * x); /*avoid underflow */ + } + return x + efx * x; + } + y = a + a * neval (z, TN1, NTN1) / deval (z, TD1, NTD1); + } + else + { + a = a - one; + y = erf_const + neval (a, TN2, NTN2) / deval (a, TD2, NTD2); + } + + if (sign & 0x80000000) /* x < 0 */ + y = -y; + return( y ); +} + +long_double_symbol (libm, __erfl, erfl); +#ifdef __STDC__ + long double + __erfcl (long double x) +#else + long double + __erfcl (x) + double + x; +#endif +{ + long double y, z, p, r; + int32_t i, ix, sign; + ieee854_long_double_shape_type u; + + u.value = x; + sign = u.parts32.w0; + ix = sign & 0x7fffffff; + u.parts32.w0 = ix; + + if (ix >= 0x7ff00000) + { /* erfc(nan)=nan */ + /* erfc(+-inf)=0,2 */ + return (long double) (((u_int32_t) sign >> 31) << 1) + one / x; + } + + if (ix < 0x3fd00000) /* |x| <1/4 */ + { + if (ix < 0x38d00000) /* |x|<2**-114 */ + return one - x; + return one - __erfl (x); + } + if (ix < 0x3ff40000) /* 1.25 */ + { + x = u.value; + i = 8.0 * x; + switch (i) + { + case 2: + z = x - 0.25L; + y = C13b + z * neval (z, RNr13, NRNr13) / deval (z, RDr13, NRDr13); + y += C13a; + break; + case 3: + z = x - 0.375L; + y = C14b + z * neval (z, RNr14, NRNr14) / deval (z, RDr14, NRDr14); + y += C14a; + break; + case 4: + z = x - 0.5L; + y = C15b + z * neval (z, RNr15, NRNr15) / deval (z, RDr15, NRDr15); + y += C15a; + break; + case 5: + z = x - 0.625L; + y = C16b + z * neval (z, RNr16, NRNr16) / deval (z, RDr16, NRDr16); + y += C16a; + break; + case 6: + z = x - 0.75L; + y = C17b + z * neval (z, RNr17, NRNr17) / deval (z, RDr17, NRDr17); + y += C17a; + break; + case 7: + z = x - 0.875L; + y = C18b + z * neval (z, RNr18, NRNr18) / deval (z, RDr18, NRDr18); + y += C18a; + break; + case 8: + z = x - 1.0L; + y = C19b + z * neval (z, RNr19, NRNr19) / deval (z, RDr19, NRDr19); + y += C19a; + break; + case 9: + z = x - 1.125L; + y = C20b + z * neval (z, RNr20, NRNr20) / deval (z, RDr20, NRDr20); + y += C20a; + break; + } + if (sign & 0x80000000) + y = 2.0L - y; + return y; + } + /* 1.25 < |x| < 107 */ + if (ix < 0x405ac000) + { + /* x < -9 */ + if ((ix >= 0x40220000) && (sign & 0x80000000)) + return two - tiny; + + x = fabsl (x); + z = one / (x * x); + i = 8.0 / x; + switch (i) + { + default: + case 0: + p = neval (z, RNr1, NRNr1) / deval (z, RDr1, NRDr1); + break; + case 1: + p = neval (z, RNr2, NRNr2) / deval (z, RDr2, NRDr2); + break; + case 2: + p = neval (z, RNr3, NRNr3) / deval (z, RDr3, NRDr3); + break; + case 3: + p = neval (z, RNr4, NRNr4) / deval (z, RDr4, NRDr4); + break; + case 4: + p = neval (z, RNr5, NRNr5) / deval (z, RDr5, NRDr5); + break; + case 5: + p = neval (z, RNr6, NRNr6) / deval (z, RDr6, NRDr6); + break; + case 6: + p = neval (z, RNr7, NRNr7) / deval (z, RDr7, NRDr7); + break; + case 7: + p = neval (z, RNr8, NRNr8) / deval (z, RDr8, NRDr8); + break; + } + u.value = x; + u.parts32.w3 = 0; + u.parts32.w2 &= 0xffffe000; + z = u.value; + r = __ieee754_expl (-z * z - 0.5625) * + __ieee754_expl ((z - x) * (z + x) + p); + if ((sign & 0x80000000) == 0) + return r / x; + else + return two - r / x; + } + else + { + if ((sign & 0x80000000) == 0) + return tiny * tiny; + else + return two - tiny; + } +} + +long_double_symbol (libm, __erfcl, erfcl); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_expm1l.c b/sysdeps/ieee754/ldbl-128ibm/s_expm1l.c new file mode 100644 index 0000000..4908d4e --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_expm1l.c @@ -0,0 +1,160 @@ +/* expm1l.c + * + * Exponential function, minus 1 + * 128-bit long double precision + * + * + * + * SYNOPSIS: + * + * long double x, y, expm1l(); + * + * y = expm1l( x ); + * + * + * + * DESCRIPTION: + * + * Returns e (2.71828...) raised to the x power, minus one. + * + * Range reduction is accomplished by separating the argument + * into an integer k and fraction f such that + * + * x k f + * e = 2 e. + * + * An expansion x + .5 x^2 + x^3 R(x) approximates exp(f) - 1 + * in the basic range [-0.5 ln 2, 0.5 ln 2]. + * + * + * ACCURACY: + * + * Relative error: + * arithmetic domain # trials peak rms + * IEEE -79,+MAXLOG 100,000 1.7e-34 4.5e-35 + * + */ + +/* Copyright 2001 by Stephen L. Moshier + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include "math.h" +#include "math_private.h" +#include + +/* exp(x) - 1 = x + 0.5 x^2 + x^3 P(x)/Q(x) + -.5 ln 2 < x < .5 ln 2 + Theoretical peak relative error = 8.1e-36 */ + +static const long double + P0 = 2.943520915569954073888921213330863757240E8L, + P1 = -5.722847283900608941516165725053359168840E7L, + P2 = 8.944630806357575461578107295909719817253E6L, + P3 = -7.212432713558031519943281748462837065308E5L, + P4 = 4.578962475841642634225390068461943438441E4L, + P5 = -1.716772506388927649032068540558788106762E3L, + P6 = 4.401308817383362136048032038528753151144E1L, + P7 = -4.888737542888633647784737721812546636240E-1L, + Q0 = 1.766112549341972444333352727998584753865E9L, + Q1 = -7.848989743695296475743081255027098295771E8L, + Q2 = 1.615869009634292424463780387327037251069E8L, + Q3 = -2.019684072836541751428967854947019415698E7L, + Q4 = 1.682912729190313538934190635536631941751E6L, + Q5 = -9.615511549171441430850103489315371768998E4L, + Q6 = 3.697714952261803935521187272204485251835E3L, + Q7 = -8.802340681794263968892934703309274564037E1L, + /* Q8 = 1.000000000000000000000000000000000000000E0 */ +/* C1 + C2 = ln 2 */ + + C1 = 6.93145751953125E-1L, + C2 = 1.428606820309417232121458176568075500134E-6L, +/* ln (2^16384 * (1 - 2^-113)) */ + maxlog = 1.1356523406294143949491931077970764891253E4L, +/* ln 2^-114 */ + minarg = -7.9018778583833765273564461846232128760607E1L, big = 2e307L; + + +long double +__expm1l (long double x) +{ + long double px, qx, xx; + int32_t ix, sign; + ieee854_long_double_shape_type u; + int k; + + /* Detect infinity and NaN. */ + u.value = x; + ix = u.parts32.w0; + sign = ix & 0x80000000; + ix &= 0x7fffffff; + if (ix >= 0x7ff00000) + { + /* Infinity. */ + if (((ix & 0xfffff) | u.parts32.w1 | (u.parts32.w2&0x7fffffff) | u.parts32.w3) == 0) + { + if (sign) + return -1.0L; + else + return x; + } + /* NaN. No invalid exception. */ + return x; + } + + /* expm1(+- 0) = +- 0. */ + if ((ix == 0) && (u.parts32.w1 | (u.parts32.w2&0x7fffffff) | u.parts32.w3) == 0) + return x; + + /* Overflow. */ + if (x > maxlog) + return (big * big); + + /* Minimum value. */ + if (x < minarg) + return (4.0/big - 1.0L); + + /* Express x = ln 2 (k + remainder), remainder not exceeding 1/2. */ + xx = C1 + C2; /* ln 2. */ + px = __floorl (0.5 + x / xx); + k = px; + /* remainder times ln 2 */ + x -= px * C1; + x -= px * C2; + + /* Approximate exp(remainder ln 2). */ + px = (((((((P7 * x + + P6) * x + + P5) * x + P4) * x + P3) * x + P2) * x + P1) * x + P0) * x; + + qx = (((((((x + + Q7) * x + + Q6) * x + Q5) * x + Q4) * x + Q3) * x + Q2) * x + Q1) * x + Q0; + + xx = x * x; + qx = x + (0.5 * xx + xx * px / qx); + + /* exp(x) = exp(k ln 2) exp(remainder ln 2) = 2^k exp(remainder ln 2). + + We have qx = exp(remainder ln 2) - 1, so + exp(x) - 1 = 2^k (qx + 1) - 1 + = 2^k qx + 2^k - 1. */ + + px = ldexpl (1.0L, k); + x = px * qx + (px - 1.0); + return x; +} +libm_hidden_def (__expm1l) +long_double_symbol (libm, __expm1l, expm1l); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_fabsl.c b/sysdeps/ieee754/ldbl-128ibm/s_fabsl.c new file mode 100644 index 0000000..6266312 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_fabsl.c @@ -0,0 +1,43 @@ +/* s_fabsl.c -- long double version of s_fabs.c. + * Conversion to IEEE quad long double by Jakub Jelinek, jj@ultra.linux.cz. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + + +/* + * fabsl(x) returns the absolute value of x. + */ + +#include "math.h" +#include "math_private.h" +#include + +#ifdef __STDC__ + long double __fabsl(long double x) +#else + long double __fabsl(x) + long double x; +#endif +{ + u_int64_t hx, lx; + GET_LDOUBLE_WORDS64(hx,lx,x); + lx = lx ^ ( hx & 0x8000000000000000LL ); + hx = hx & 0x7fffffffffffffffLL; + SET_LDOUBLE_WORDS64(hx,lx,x); + return x; +} +long_double_symbol (libm, __fabsl, fabsl); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_finitel.c b/sysdeps/ieee754/ldbl-128ibm/s_finitel.c new file mode 100644 index 0000000..142d3ed --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_finitel.c @@ -0,0 +1,42 @@ +/* s_finitel.c -- long double version of s_finite.c. + * Conversion to IEEE quad long double by Jakub Jelinek, jj@ultra.linux.cz. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * finitel(x) returns 1 is x is finite, else 0; + * no branching! + */ + +#include "math.h" +#include "math_private.h" +#include + +int +___finitel (long double x) +{ + int64_t hx; + GET_LDOUBLE_MSW64(hx,x); + return (int)((u_int64_t)((hx&0x7fffffffffffffffLL) + -0x7ff0000000000000LL)>>63); +} +hidden_ver (___finitel, __finitel) +#ifndef IS_IN_libm +weak_alias (___finitel, ____finitel) +long_double_symbol (libc, ___finitel, finitel); +long_double_symbol (libc, ____finitel, __finitel); +#endif diff --git a/sysdeps/ieee754/ldbl-128ibm/s_floorl.c b/sysdeps/ieee754/ldbl-128ibm/s_floorl.c new file mode 100644 index 0000000..e8ef6e8 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_floorl.c @@ -0,0 +1,118 @@ +/* Round to int long double floating-point values. + IBM extended format long double version. + Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* This has been coded in assembler because GCC makes such a mess of it + when it's coded in C. */ + +#include +#include +#include +#include +#include + + +#ifdef __STDC__ +long double +__floorl (long double x) +#else +long double +__floorl (x) + long double x; +#endif +{ + static const double TWO52 = 4503599627370496.0L; + int mode = fegetround(); + union ibm_extended_long_double u; + + u.d = x; + + if (fabs (u.dd[0]) < TWO52) + { + fesetround(FE_DOWNWARD); + if (u.dd[0] > 0.0) + { + u.dd[0] += TWO52; + u.dd[0] -= TWO52; + } + else if (u.dd[0] < 0.0) + { + u.dd[0] -= TWO52; + u.dd[0] += TWO52; + } + u.dd[1] = 0.0; + fesetround(mode); + } + else if (fabs (u.dd[1]) < TWO52 && u.dd[1] != 0.0) + { + double high, low; + /* In this case we have to round the low double and handle any + adjustment to the high double that may be caused by rounding + (up). This is complicated by the fact that the high double + may already be rounded and the low double may have the + opposite sign to compensate. */ + if (u.dd[0] > 0.0) + { + if (u.dd[1] > 0.0) + { + /* If the high/low doubles are the same sign then simply + round the low double. */ + high = u.dd[0]; + low = u.dd[1]; + } + else if (u.dd[1] < 0.0) + { + /* Else the high double is pre rounded and we need to + adjust for that. */ + high = nextafter (u.dd[0], 0.0); + low = u.dd[1] + (u.dd[0] - high); + } + fesetround(FE_DOWNWARD); + low += TWO52; + low -= TWO52; + } + else if (u.dd[0] < 0.0) + { + if (u.dd[1] < 0.0) + { + /* If the high/low doubles are the same sign then simply + round the low double. */ + high = u.dd[0]; + low = u.dd[1]; + } + else if (u.dd[1] > 0.0) + { + /* Else the high double is pre rounded and we need to + adjust for that. */ + high = nextafter (u.dd[0], 0.0); + low = u.dd[1] + (u.dd[0] - high); + } + fesetround(FE_DOWNWARD); + low -= TWO52; + low += TWO52; + } + fesetround(mode); + u.dd[0] = high + low; + u.dd[1] = high - u.dd[0] + low; + } + + return u.d; +} + +long_double_symbol (libm, __floorl, floorl); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_fpclassifyl.c b/sysdeps/ieee754/ldbl-128ibm/s_fpclassifyl.c new file mode 100644 index 0000000..3ca178a --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_fpclassifyl.c @@ -0,0 +1,82 @@ +/* Return classification value corresponding to argument. + Copyright (C) 1997,1999,2002,2004,2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997 and + Jakub Jelinek , 1999. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include + +#include "math_private.h" +#include + + /* + * hx lx + * +NaN 7ffn nnnn nnnn nnnn xxxx xxxx xxxx xxxx + * -NaN fffn nnnn nnnn nnnn xxxx xxxx xxxx xxxx + * +Inf 7ff0 0000 0000 0000 xxxx xxxx xxxx xxxx + * -Inf fff0 0000 0000 0000 xxxx xxxx xxxx xxxx + * +0 0000 0000 0000 0000 + * -0 8000 0000 0000 0000 + * +normal 001n nnnn nnnn nnnn (smallest) + * -normal 801n nnnn nnnn nnnn (smallest) + * +normal 7fen nnnn nnnn nnnn (largest) + * -normal ffen nnnn nnnn nnnn (largest) + * +denorm 000n nnnn nnnn nnnn + * -denorm 800n nnnn nnnn nnnn + */ + +int +___fpclassifyl (long double x) +{ + u_int64_t hx, lx; + int retval = FP_NORMAL; + + GET_LDOUBLE_WORDS64 (hx, lx, x); + if ((hx & 0x7ff0000000000000ULL) == 0x7ff0000000000000ULL) { + /* +/-NaN or +/-Inf */ + if (hx & 0x000fffffffffffffULL) { + /* +/-NaN */ + retval = FP_NAN; + } else { + retval = FP_INFINITE; + } + } else { + /* +/-zero or +/- normal or +/- denormal */ + if (hx & 0x7fffffffffffffffULL) { + /* +/- normal or +/- denormal */ + if ((hx & 0x7ff0000000000000ULL) >= 0x0360000000000000ULL) { + /* +/- normal */ + retval = FP_NORMAL; + } else { + /* +/- denormal */ + retval = FP_SUBNORMAL; + } + } else { + /* +/- zero */ + retval = FP_ZERO; + } + } + + return retval; +} +long_double_symbol (libm, ___fpclassifyl, __fpclassifyl); +#ifdef __LONG_DOUBLE_MATH_OPTIONAL +libm_hidden_ver (___fpclassifyl, __fpclassifyl) +#else +libm_hidden_def (__fpclassifyl) +#endif diff --git a/sysdeps/ieee754/ldbl-128ibm/s_frexpl.c b/sysdeps/ieee754/ldbl-128ibm/s_frexpl.c new file mode 100644 index 0000000..fab566d --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_frexpl.c @@ -0,0 +1,92 @@ +/* s_frexpl.c -- long double version of s_frexp.c. + * Conversion to IEEE quad long double by Jakub Jelinek, jj@ultra.linux.cz. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * for non-zero x + * x = frexpl(arg,&exp); + * return a long double fp quantity x such that 0.5 <= |x| <1.0 + * and the corresponding binary exponent "exp". That is + * arg = x*2^exp. + * If arg is inf, 0.0, or NaN, then frexpl(arg,&exp) returns arg + * with *exp=0. + */ + +#include "math.h" +#include "math_private.h" +#include + +#ifdef __STDC__ +static const long double +#else +static long double +#endif +two107 = 162259276829213363391578010288128.0; /* 0x4670000000000000, 0 */ + +#ifdef __STDC__ + long double __frexpl(long double x, int *eptr) +#else + long double __frexpl(x, eptr) + long double x; int *eptr; +#endif +{ + u_int64_t hx, lx, ix, ixl; + int64_t explo; + GET_LDOUBLE_WORDS64(hx,lx,x); + ixl = 0x7fffffffffffffffULL&lx; + ix = 0x7fffffffffffffffULL&hx; + *eptr = 0; + if(ix>=0x7ff0000000000000ULL||((ix|ixl)==0)) return x; /* 0,inf,nan */ + if (ix<0x0010000000000000ULL) { /* subnormal */ + x *= two107; + GET_LDOUBLE_MSW64(hx,x); + ix = hx&0x7fffffffffffffffULL; + *eptr = -107; + } + *eptr += (ix>>52)-1022; + + if (ixl != 0ULL) { + explo = (ixl>>52) - (ix>>52) + 0x3fe; + if ((ixl&0x7ff0000000000000ULL) == 0LL) { + /* the lower double is a denomal so we need to correct its + mantissa and perhaps its exponent. */ + int cnt; + + if (sizeof (ixl) == sizeof (long)) + cnt = __builtin_clzl (ixl); + else if ((ixl >> 32) != 0) + cnt = __builtin_clzl ((long) (ixl >> 32)); + else + cnt = __builtin_clzl ((long) ixl) + 32; + cnt = cnt - 12; + lx = (lx&0x8000000000000000ULL) | ((explo-cnt)<<52) + | ((ixl<<(cnt+1))&0x000fffffffffffffULL); + } else + lx = (lx&0x800fffffffffffffULL) | (explo<<52); + } else + lx = 0ULL; + + hx = (hx&0x800fffffffffffffULL) | 0x3fe0000000000000ULL; + SET_LDOUBLE_WORDS64(x,hx,lx); + return x; +} +#ifdef IS_IN_libm +long_double_symbol (libm, __frexpl, frexpl); +#else +long_double_symbol (libc, __frexpl, frexpl); +#endif diff --git a/sysdeps/ieee754/ldbl-128ibm/s_ilogbl.c b/sysdeps/ieee754/ldbl-128ibm/s_ilogbl.c new file mode 100644 index 0000000..428854d --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_ilogbl.c @@ -0,0 +1,63 @@ +/* s_ilogbl.c -- long double version of s_ilogb.c. + * Conversion to IEEE quad long double by Jakub Jelinek, jj@ultra.linux.cz. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* ilogbl(long double x) + * return the binary exponent of non-zero x + * ilogbl(0) = FP_ILOGB0 + * ilogbl(NaN) = FP_ILOGBNAN (no signal is raised) + * ilogbl(+-Inf) = INT_MAX (no signal is raised) + */ + +#include +#include "math.h" +#include "math_private.h" +#include + +#ifdef __STDC__ + int __ilogbl(long double x) +#else + int __ilogbl(x) + long double x; +#endif +{ + int64_t hx,lx; + int ix; + + GET_LDOUBLE_WORDS64(hx,lx,x); + hx &= 0x7fffffffffffffffLL; + if(hx <= 0x0010000000000000LL) { + if((hx|(lx&0x7fffffffffffffffLL))==0) + return FP_ILOGB0; /* ilogbl(0) = FP_ILOGB0 */ + else /* subnormal x */ + if(hx==0) { + for (ix = -1043; lx>0; lx<<=1) ix -=1; + } else { + for (ix = -1022, hx<<=11; hx>0; hx<<=1) ix -=1; + } + return ix; + } + else if (hx<0x7ff0000000000000LL) return (hx>>52)-0x3ff; + else if (FP_ILOGBNAN != INT_MAX) { + /* ISO C99 requires ilogbl(+-Inf) == INT_MAX. */ + if (((hx^0x7ff0000000000000LL)|lx) == 0) + return INT_MAX; + } + return FP_ILOGBNAN; +} +long_double_symbol (libm, __ilogbl, ilogbl); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_isinfl.c b/sysdeps/ieee754/ldbl-128ibm/s_isinfl.c new file mode 100644 index 0000000..717b574 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_isinfl.c @@ -0,0 +1,35 @@ +/* + * Written by J.T. Conklin . + * Change for long double by Jakub Jelinek + * Public domain. + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * isinfl(x) returns 1 if x is inf, -1 if x is -inf, else 0; + * no branching! + */ + +#include "math.h" +#include "math_private.h" +#include + +int +___isinfl (long double x) +{ + int64_t hx,lx; + GET_LDOUBLE_WORDS64(hx,lx,x); + lx = (lx & 0x7fffffffffffffffLL); + lx |= (hx & 0x7fffffffffffffffLL) ^ 0x7ff0000000000000LL; + lx |= -lx; + return ~(lx >> 63) & (hx >> 62); +} +hidden_ver (___isinfl, __isinfl) +#ifndef IS_IN_libm +weak_alias (___isinfl, ____isinfl) +long_double_symbol (libc, ___isinfl, isinfl); +long_double_symbol (libc, ____isinfl, __isinfl); +#endif diff --git a/sysdeps/ieee754/ldbl-128ibm/s_isnanl.c b/sysdeps/ieee754/ldbl-128ibm/s_isnanl.c new file mode 100644 index 0000000..ae5ba8e --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_isnanl.c @@ -0,0 +1,43 @@ +/* s_isnanl.c -- long double version of s_isnan.c. + * Conversion to long double by Jakub Jelinek, jj@ultra.linux.cz. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * isnanl(x) returns 1 is x is nan, else 0; + * no branching! + */ + +#include "math.h" +#include "math_private.h" +#include + +int +___isnanl (long double x) +{ + int64_t hx,lx; + GET_LDOUBLE_WORDS64(hx,lx,x); + hx &= 0x7fffffffffffffffLL; + hx = 0x7ff0000000000000LL - hx; + return (int)((u_int64_t)hx>>63); +} +hidden_ver (___isnanl, __isnanl) +#ifndef IS_IN_libm +weak_alias (___isnanl, ____isnanl) +long_double_symbol (libc, ___isnanl, isnanl); +long_double_symbol (libc, ____isnanl, __isnanl); +#endif diff --git a/sysdeps/ieee754/ldbl-128ibm/s_llrintl.c b/sysdeps/ieee754/ldbl-128ibm/s_llrintl.c new file mode 100644 index 0000000..bacf1be --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_llrintl.c @@ -0,0 +1,124 @@ +/* Round to int long double floating-point values. + IBM extended format long double version. + Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* This has been coded in assembler because GCC makes such a mess of it + when it's coded in C. */ + +#include +#include +#include +#include + + +#ifdef __STDC__ +long long +__llrintl (long double x) +#else +long long +__llrintl (x) + long double x; +#endif +{ + static const double TWO52 = 4503599627370496.0L; + union ibm_extended_long_double u; + long long result = __LONG_LONG_MAX__; + + u.d = x; + + if (fabs (u.dd[0]) < TWO52) + { + double high = u.dd[0]; + if (high > 0.0) + { + high += TWO52; + high -= TWO52; + if (high == -0.0) high = 0.0; + } + else if (high < 0.0) + { + high -= TWO52; + high += TWO52; + if (high == 0.0) high = -0.0; + } + result = high; + } + else if (fabs (u.dd[1]) < TWO52 && u.dd[1] != 0.0) + { + double high, low, tau; + long long lowint; + /* In this case we have to round the low double and handle any + adjustment to the high double that may be caused by rounding + (up). This is complicated by the fact that the high double + may already be rounded and the low double may have the + opposite sign to compensate. */ + if (u.dd[0] > 0.0) + { + if (u.dd[1] > 0.0) + { + /* If the high/low doubles are the same sign then simply + round the low double. */ + high = u.dd[0]; + low = u.dd[1]; + } + else if (u.dd[1] < 0.0) + { + /* Else the high double is pre rounded and we need to + adjust for that. */ + + tau = nextafter (u.dd[0], 0.0); + tau = (u.dd[0] - tau) * 2.0; + high = u.dd[0] - tau; + low = u.dd[1] + tau; + } + low += TWO52; + low -= TWO52; + } + else if (u.dd[0] < 0.0) + { + if (u.dd[1] < 0.0) + { + /* If the high/low doubles are the same sign then simply + round the low double. */ + high = u.dd[0]; + low = u.dd[1]; + } + else if (u.dd[1] > 0.0) + { + /* Else the high double is pre rounded and we need to + adjust for that. */ + tau = nextafter (u.dd[0], 0.0); + tau = (u.dd[0] - tau) * 2.0; + high = u.dd[0] - tau; + low = u.dd[1] + tau; + } + low = TWO52 - low; + low = -(low - TWO52); + } + lowint = low; + result = high; + result += lowint; + } + else + result = u.dd[0]; + + return result; +} + +long_double_symbol (libm, __llrintl, llrintl); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_llroundl.c b/sysdeps/ieee754/ldbl-128ibm/s_llroundl.c new file mode 100644 index 0000000..567e7ec --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_llroundl.c @@ -0,0 +1,128 @@ +/* Round to long long, long double floating-point values. + IBM extended format long double version. + Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* This has been coded in assembler because GCC makes such a mess of it + when it's coded in C. */ + +#include +#include +#include +#include +#include + + +#ifdef __STDC__ +long long +__llroundl (long double x) +#else +long long +__llroundl (x) + long double x; +#endif +{ + static const double TWO52 = 4503599627370496.0; + static const double HALF = 0.5; + int mode = fegetround(); + union ibm_extended_long_double u; + long long result = __LONG_LONG_MAX__; + + u.d = x; + + if (fabs (u.dd[0]) < TWO52) + { + fesetround(FE_TOWARDZERO); + if (u.dd[0] > 0.0) + { + u.dd[0] += HALF; + u.dd[0] += TWO52; + u.dd[0] -= TWO52; + } + else if (u.dd[0] < 0.0) + { + u.dd[0] = TWO52 - (u.dd[0] - HALF); + u.dd[0] = -(u.dd[0] - TWO52); + } + fesetround(mode); + result = u.dd[0]; + } + else if (fabs (u.dd[1]) < TWO52 && u.dd[1] != 0.0) + { + double high, low; + long long lowint; + /* In this case we have to round the low double and handle any + adjustment to the high double that may be caused by rounding + (up). This is complicated by the fact that the high double + may already be rounded and the low double may have the + opposite sign to compensate. */ + if (u.dd[0] > 0.0) + { + if (u.dd[1] > 0.0) + { + /* If the high/low doubles are the same sign then simply + round the low double. */ + high = u.dd[0]; + low = u.dd[1]; + } + else if (u.dd[1] < 0.0) + { + /* Else the high double is pre rounded and we need to + adjust for that. */ + high = nextafter (u.dd[0], 0.0); + low = u.dd[1] + (u.dd[0] - high); + } + fesetround(FE_TOWARDZERO); + low += HALF; + low += TWO52; + low -= TWO52; + } + else if (u.dd[0] < 0.0) + { + if (u.dd[1] < 0.0) + { + /* If the high/low doubles are the same sign then simply + round the low double. */ + high = u.dd[0]; + low = u.dd[1]; + } + else if (u.dd[1] > 0.0) + { + /* Else the high double is pre rounded and we need to + adjust for that. */ + high = nextafter (u.dd[0], 0.0); + low = u.dd[1] + (u.dd[0] - high); + } + fesetround(FE_TOWARDZERO); + low -= HALF; + low = TWO52 - low; + low = -(low - TWO52); + } + fesetround(mode); + lowint = low; + result = high; + result += lowint; + } + else + { + result = u.dd[0]; + } + return result; +} + +long_double_symbol (libm, __llroundl, llroundl); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_log1pl.c b/sysdeps/ieee754/ldbl-128ibm/s_log1pl.c new file mode 100644 index 0000000..f1863fb --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_log1pl.c @@ -0,0 +1,257 @@ +/* log1pl.c + * + * Relative error logarithm + * Natural logarithm of 1+x, 128-bit long double precision + * + * + * + * SYNOPSIS: + * + * long double x, y, log1pl(); + * + * y = log1pl( x ); + * + * + * + * DESCRIPTION: + * + * Returns the base e (2.718...) logarithm of 1+x. + * + * The argument 1+x is separated into its exponent and fractional + * parts. If the exponent is between -1 and +1, the logarithm + * of the fraction is approximated by + * + * log(1+x) = x - 0.5 x^2 + x^3 P(x)/Q(x). + * + * Otherwise, setting z = 2(w-1)/(w+1), + * + * log(w) = z + z^3 P(z)/Q(z). + * + * + * + * ACCURACY: + * + * Relative error: + * arithmetic domain # trials peak rms + * IEEE -1, 8 100000 1.9e-34 4.3e-35 + */ + +/* Copyright 2001 by Stephen L. Moshier + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + + +#include "math.h" +#include "math_private.h" +#include + +/* Coefficients for log(1+x) = x - x^2 / 2 + x^3 P(x)/Q(x) + * 1/sqrt(2) <= 1+x < sqrt(2) + * Theoretical peak relative error = 5.3e-37, + * relative peak error spread = 2.3e-14 + */ +static const long double + P12 = 1.538612243596254322971797716843006400388E-6L, + P11 = 4.998469661968096229986658302195402690910E-1L, + P10 = 2.321125933898420063925789532045674660756E1L, + P9 = 4.114517881637811823002128927449878962058E2L, + P8 = 3.824952356185897735160588078446136783779E3L, + P7 = 2.128857716871515081352991964243375186031E4L, + P6 = 7.594356839258970405033155585486712125861E4L, + P5 = 1.797628303815655343403735250238293741397E5L, + P4 = 2.854829159639697837788887080758954924001E5L, + P3 = 3.007007295140399532324943111654767187848E5L, + P2 = 2.014652742082537582487669938141683759923E5L, + P1 = 7.771154681358524243729929227226708890930E4L, + P0 = 1.313572404063446165910279910527789794488E4L, + /* Q12 = 1.000000000000000000000000000000000000000E0L, */ + Q11 = 4.839208193348159620282142911143429644326E1L, + Q10 = 9.104928120962988414618126155557301584078E2L, + Q9 = 9.147150349299596453976674231612674085381E3L, + Q8 = 5.605842085972455027590989944010492125825E4L, + Q7 = 2.248234257620569139969141618556349415120E5L, + Q6 = 6.132189329546557743179177159925690841200E5L, + Q5 = 1.158019977462989115839826904108208787040E6L, + Q4 = 1.514882452993549494932585972882995548426E6L, + Q3 = 1.347518538384329112529391120390701166528E6L, + Q2 = 7.777690340007566932935753241556479363645E5L, + Q1 = 2.626900195321832660448791748036714883242E5L, + Q0 = 3.940717212190338497730839731583397586124E4L; + +/* Coefficients for log(x) = z + z^3 P(z^2)/Q(z^2), + * where z = 2(x-1)/(x+1) + * 1/sqrt(2) <= x < sqrt(2) + * Theoretical peak relative error = 1.1e-35, + * relative peak error spread 1.1e-9 + */ +static const long double + R5 = -8.828896441624934385266096344596648080902E-1L, + R4 = 8.057002716646055371965756206836056074715E1L, + R3 = -2.024301798136027039250415126250455056397E3L, + R2 = 2.048819892795278657810231591630928516206E4L, + R1 = -8.977257995689735303686582344659576526998E4L, + R0 = 1.418134209872192732479751274970992665513E5L, + /* S6 = 1.000000000000000000000000000000000000000E0L, */ + S5 = -1.186359407982897997337150403816839480438E2L, + S4 = 3.998526750980007367835804959888064681098E3L, + S3 = -5.748542087379434595104154610899551484314E4L, + S2 = 4.001557694070773974936904547424676279307E5L, + S1 = -1.332535117259762928288745111081235577029E6L, + S0 = 1.701761051846631278975701529965589676574E6L; + +/* C1 + C2 = ln 2 */ +static const long double C1 = 6.93145751953125E-1L; +static const long double C2 = 1.428606820309417232121458176568075500134E-6L; + +static const long double sqrth = 0.7071067811865475244008443621048490392848L; +/* ln (2^16384 * (1 - 2^-113)) */ +static const long double maxlog = 1.1356523406294143949491931077970764891253E4L; +static const long double big = 2e300L; +static const long double zero = 0.0L; + +#if 1 +/* Make sure these are prototyped. */ +long double frexpl (long double, int *); +long double ldexpl (long double, int); +#endif + + +long double +__log1pl (long double xm1) +{ + long double x, y, z, r, s; + ieee854_long_double_shape_type u; + int32_t hx; + int e; + + /* Test for NaN or infinity input. */ + u.value = xm1; + hx = u.parts32.w0; + if (hx >= 0x7ff00000) + return xm1; + + /* log1p(+- 0) = +- 0. */ + if (((hx & 0x7fffffff) == 0) + && (u.parts32.w1 | (u.parts32.w2 & 0x7fffffff) | u.parts32.w3) == 0) + return xm1; + + x = xm1 + 1.0L; + + /* log1p(-1) = -inf */ + if (x <= 0.0L) + { + if (x == 0.0L) + return (-1.0L / (x - x)); + else + return (zero / (x - x)); + } + + /* Separate mantissa from exponent. */ + + /* Use frexp used so that denormal numbers will be handled properly. */ + x = frexpl (x, &e); + + /* Logarithm using log(x) = z + z^3 P(z^2)/Q(z^2), + where z = 2(x-1)/x+1). */ + if ((e > 2) || (e < -2)) + { + if (x < sqrth) + { /* 2( 2x-1 )/( 2x+1 ) */ + e -= 1; + z = x - 0.5L; + y = 0.5L * z + 0.5L; + } + else + { /* 2 (x-1)/(x+1) */ + z = x - 0.5L; + z -= 0.5L; + y = 0.5L * x + 0.5L; + } + x = z / y; + z = x * x; + r = ((((R5 * z + + R4) * z + + R3) * z + + R2) * z + + R1) * z + + R0; + s = (((((z + + S5) * z + + S4) * z + + S3) * z + + S2) * z + + S1) * z + + S0; + z = x * (z * r / s); + z = z + e * C2; + z = z + x; + z = z + e * C1; + return (z); + } + + + /* Logarithm using log(1+x) = x - .5x^2 + x^3 P(x)/Q(x). */ + + if (x < sqrth) + { + e -= 1; + if (e != 0) + x = 2.0L * x - 1.0L; /* 2x - 1 */ + else + x = xm1; + } + else + { + if (e != 0) + x = x - 1.0L; + else + x = xm1; + } + z = x * x; + r = (((((((((((P12 * x + + P11) * x + + P10) * x + + P9) * x + + P8) * x + + P7) * x + + P6) * x + + P5) * x + + P4) * x + + P3) * x + + P2) * x + + P1) * x + + P0; + s = (((((((((((x + + Q11) * x + + Q10) * x + + Q9) * x + + Q8) * x + + Q7) * x + + Q6) * x + + Q5) * x + + Q4) * x + + Q3) * x + + Q2) * x + + Q1) * x + + Q0; + y = x * (z * r / s); + y = y + e * C2; + z = y - 0.5L * z; + z = z + x; + z = z + e * C1; + return (z); +} + +long_double_symbol (libm, __log1pl, log1pl); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_logbl.c b/sysdeps/ieee754/ldbl-128ibm/s_logbl.c new file mode 100644 index 0000000..0c61cda --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_logbl.c @@ -0,0 +1,47 @@ +/* s_logbl.c -- long double version of s_logb.c. + * Conversion to IEEE quad long double by Jakub Jelinek, jj@ultra.linux.cz. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * long double logbl(x) + * IEEE 754 logb. Included to pass IEEE test suite. Not recommend. + * Use ilogb instead. + */ + +#include "math.h" +#include "math_private.h" +#include + +#ifdef __STDC__ + long double __logbl(long double x) +#else + long double __logbl(x) + long double x; +#endif +{ + int64_t lx,hx; + GET_LDOUBLE_WORDS64(hx,lx,x); + hx &= 0x7fffffffffffffffLL; /* high |x| */ + if((hx|(lx&0x7fffffffffffffffLL))==0) return -1.0/fabs(x); + if(hx>=0x7ff0000000000000LL) return x*x; + if((hx>>=52)==0) /* IEEE 754 logb */ + return -1022.0; + else + return (long double) (hx-0x3ff); +} +long_double_symbol (libm, __logbl, logbl); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_lrintl.c b/sysdeps/ieee754/ldbl-128ibm/s_lrintl.c new file mode 100644 index 0000000..0292475 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_lrintl.c @@ -0,0 +1,9 @@ +/* FIXME */ +#include +#include + +long int __lrintl (long double d) +{ + return llrintl (d); +} +long_double_symbol (libm, __lrintl, lrintl); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_lroundl.c b/sysdeps/ieee754/ldbl-128ibm/s_lroundl.c new file mode 100644 index 0000000..7c5de36 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_lroundl.c @@ -0,0 +1,9 @@ +/* FIXME */ +#include +#include + +long int __lroundl (long double d) +{ + return llroundl (d); +} +long_double_symbol (libm, __lroundl, lroundl); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_modfl.c b/sysdeps/ieee754/ldbl-128ibm/s_modfl.c new file mode 100644 index 0000000..f2e65f0 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_modfl.c @@ -0,0 +1,94 @@ +/* s_modfl.c -- long double version of s_modf.c. + * Conversion to IEEE quad long double by Jakub Jelinek, jj@ultra.linux.cz. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * modfl(long double x, long double *iptr) + * return fraction part of x, and return x's integral part in *iptr. + * Method: + * Bit twiddling. + * + * Exception: + * No exception. + */ + +#include "math.h" +#include "math_private.h" +#include + +#ifdef __STDC__ +static const long double one = 1.0; +#else +static long double one = 1.0; +#endif + +#ifdef __STDC__ + long double __modfl(long double x, long double *iptr) +#else + long double __modfl(x, iptr) + long double x,*iptr; +#endif +{ + int64_t i0,i1,j0; + u_int64_t i; + GET_LDOUBLE_WORDS64(i0,i1,x); + i1 &= 0x000fffffffffffffLL; + j0 = ((i0>>52)&0x7ff)-0x3ff; /* exponent of x */ + if(j0<52) { /* integer part in high x */ + if(j0<0) { /* |x|<1 */ + /* *iptr = +-0 */ + SET_LDOUBLE_WORDS64(*iptr,i0&0x8000000000000000ULL,0); + return x; + } else { + i = (0x000fffffffffffffLL)>>j0; + if(((i0&i)|(i1&0x7fffffffffffffffLL))==0) { /* x is integral */ + *iptr = x; + /* return +-0 */ + SET_LDOUBLE_WORDS64(x,i0&0x8000000000000000ULL,0); + return x; + } else { + SET_LDOUBLE_WORDS64(*iptr,i0&(~i),0); + return x - *iptr; + } + } + } else if (j0>103) { /* no fraction part */ + *iptr = x*one; + /* We must handle NaNs separately. */ + if (j0 == 0x400 && ((i0 & 0x000fffffffffffffLL) | i1)) + return x*one; + /* return +-0 */ + SET_LDOUBLE_WORDS64(x,i0&0x8000000000000000ULL,0); + return x; + } else { /* fraction part in low x */ + i = -1ULL>>(j0-52); + if((i1&i)==0) { /* x is integral */ + *iptr = x; + /* return +-0 */ + SET_LDOUBLE_WORDS64(x,i0&0x8000000000000000ULL,0); + return x; + } else { + SET_LDOUBLE_WORDS64(*iptr,i0,i1&(~i)); + return x - *iptr; + } + } +} +#ifdef IS_IN_libm +long_double_symbol (libm, __modfl, modfl); +#else +long_double_symbol (libc, __modfl, modfl); +#endif diff --git a/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c b/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c new file mode 100644 index 0000000..2561fda --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c @@ -0,0 +1,125 @@ +/* Round to int long double floating-point values without raising inexact. + IBM extended format long double version. + Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* This has been coded in assembler because GCC makes such a mess of it + when it's coded in C. */ + +#include +#include +#include +#include +#include + + +#ifdef __STDC__ +long double +__nearbyintl (long double x) +#else +long double +__nearbyintl (x) + long double x; +#endif +{ + fenv_t env; + static const long double TWO52 = 4503599627370496.0L; + union ibm_extended_long_double u; + u.d = x; + + if (fabs (u.dd[0]) < TWO52) + { + double high = u.dd[0]; + feholdexcept (&env); + if (high > 0.0) + { + high += TWO52; + high -= TWO52; + if (high == -0.0) high = 0.0; + } + else if (high < 0.0) + { + high -= TWO52; + high += TWO52; + if (high == 0.0) high = -0.0; + } + u.dd[0] = high; + u.dd[1] = 0.0; + fesetenv (&env); + } + else if (fabs (u.dd[1]) < TWO52 && u.dd[1] != 0.0) + { + double high, low, tau; + /* In this case we have to round the low double and handle any + adjustment to the high double that may be caused by rounding + (up). This is complicated by the fact that the high double + may already be rounded and the low double may have the + opposite sign to compensate. */ + feholdexcept (&env); + if (u.dd[0] > 0.0) + { + if (u.dd[1] > 0.0) + { + /* If the high/low doubles are the same sign then simply + round the low double. */ + high = u.dd[0]; + low = u.dd[1]; + } + else if (u.dd[1] < 0.0) + { + /* Else the high double is pre rounded and we need to + adjust for that. */ + + tau = nextafter (u.dd[0], 0.0); + tau = (u.dd[0] - tau) * 2.0; + high = u.dd[0] - tau; + low = u.dd[1] + tau; + } + low += TWO52; + low -= TWO52; + } + else if (u.dd[0] < 0.0) + { + if (u.dd[1] < 0.0) + { + /* If the high/low doubles are the same sign then simply + round the low double. */ + high = u.dd[0]; + low = u.dd[1]; + } + else if (u.dd[1] > 0.0) + { + /* Else the high double is pre rounded and we need to + adjust for that. */ + tau = nextafter (u.dd[0], 0.0); + tau = (u.dd[0] - tau) * 2.0; + high = u.dd[0] - tau; + low = u.dd[1] + tau; + } + low = TWO52 - low; + low = -(low - TWO52); + } + u.dd[0] = high + low; + u.dd[1] = high - u.dd[0] + low; + fesetenv (&env); + } + + return u.d; +} + +long_double_symbol (libm, __nearbyintl, nearbyintl); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c b/sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c new file mode 100644 index 0000000..e35ce50 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c @@ -0,0 +1,108 @@ +/* s_nextafterl.c -- long double version of s_nextafter.c. + * Conversion to IEEE quad long double by Jakub Jelinek, jj@ultra.linux.cz. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* IEEE functions + * nextafterl(x,y) + * return the next machine floating-point number of x in the + * direction toward y. + * Special cases: + */ + +#include "math.h" +#include "math_private.h" +#include + +#ifdef __STDC__ + long double __nextafterl(long double x, long double y) +#else + long double __nextafterl(x,y) + long double x,y; +#endif +{ + int64_t hx,hy,ihx,ihy,ilx,ily; + u_int64_t lx,ly; + + GET_LDOUBLE_WORDS64(hx,lx,x); + GET_LDOUBLE_WORDS64(hy,ly,y); + ihx = hx&0x7fffffffffffffffLL; /* |hx| */ + ilx = lx&0x7fffffffffffffffLL; /* |lx| */ + ihy = hy&0x7fffffffffffffffLL; /* |hy| */ + ily = ly&0x7fffffffffffffffLL; /* |ly| */ + + if((((ihx&0x7ff0000000000000LL)==0x7ff0000000000000LL)&& + ((ihx&0x000fffffffffffffLL)!=0)) || /* x is nan */ + (((ihy&0x7ff0000000000000LL)==0x7ff0000000000000LL)&& + ((ihy&0x000fffffffffffffLL)!=0))) /* y is nan */ + return x+y; /* signal the nan */ + if(x==y) + return y; /* x=y, return y */ + if(ihx == 0 && ilx == 0) { /* x == 0 */ + SET_LDOUBLE_WORDS64(x,hy&0x8000000000000000ULL,1);/* return +-minsubnormal */ + y = x*x; + if(y==x) return y; else return x; /* raise underflow flag */ + } + if(ihx>=0) { /* x > 0 */ + if(ihx>ihy||((ihx==ihy)&&(ilx>ily))) { /* x > y, x -= ulp */ + + if(ilx==0) + hx--; + else + lx--; + } else { /* x < y, x += ulp */ + if((hx==0x7fefffffffffffffLL)&&(lx==0x7c8ffffffffffffeLL)) + { + SET_LDOUBLE_WORDS64(x,0x7ff0000000000000,0x8000000000000000); + return x; + } + else if((hx==0xffefffffffffffffLL)&&(lx==0xfc8ffffffffffffeLL)) + { + SET_LDOUBLE_WORDS64(x,0xfff0000000000000,0x8000000000000000); + return x; + } + else if((lx&0x7fffffffffffffff)==0) hx++; + else + lx++; + } + } else { /* x < 0 */ + if(ihy>=0||ihx>ihy||((ihx==ihy)&&(ilx>ily))){/* x < y, x -= ulp */ + if((lx&0x7fffffffffffffff)==0) + hx--; + else + lx--; + } else { /* x > y, x += ulp */ + if((lx&0x7fffffffffffffff)==0) hx++; + else + lx++; + } + } + hy = hx&0x7ff0000000000000LL; + if(hy==0x7ff0000000000000LL) return x+x;/* overflow */ + if(hy==0) { /* underflow */ + y = x*x; + if(y!=x) { /* raise underflow flag */ + SET_LDOUBLE_WORDS64(y,hx,lx); + return y; + } + } + SET_LDOUBLE_WORDS64(x,hx,lx); + return x; +} +strong_alias (__nextafterl, __nexttowardl) +long_double_symbol (libm, __nextafterl, nextafterl); +long_double_symbol (libm, __nexttowardl, nexttowardl); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c b/sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c new file mode 100644 index 0000000..3335100 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c @@ -0,0 +1,106 @@ +/* s_nexttoward.c + * Conversion from s_nextafter.c by Ulrich Drepper, Cygnus Support, + * drepper@cygnus.com and Jakub Jelinek, jj@ultra.linux.cz. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* IEEE functions + * nexttoward(x,y) + * return the next machine floating-point number of x in the + * direction toward y. + * Special cases: + */ + +#include "math.h" +#include "math_private.h" +#include +#include + +#ifdef __STDC__ + double __nexttoward(double x, long double y) +#else + double __nexttoward(x,y) + double x; + long double y; +#endif +{ + int32_t hx,ix; + int64_t hy,iy; + u_int32_t lx; + u_int64_t ly,uly; + + EXTRACT_WORDS(hx,lx,x); + GET_LDOUBLE_WORDS64(hy,ly,y); + ix = hx&0x7fffffff; /* |x| */ + iy = hy&0x7fffffffffffffffLL; /* |y| */ + uly = ly&0x7fffffffffffffffLL; /* |y| */ + + if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) || /* x is nan */ + ((iy>=0x7ff0000000000000LL)&&((iy-0x7ff0000000000000LL)|uly)!=0)) + /* y is nan */ + return x+y; + if((long double) x==y) return y; /* x=y, return y */ + if((ix|lx)==0) { /* x == 0 */ + double x2; + INSERT_WORDS(x,(u_int32_t)((hy>>32)&0x80000000),1);/* return +-minsub */ + x2 = x*x; + if(x2==x) return x2; else return x; /* raise underflow flag */ + } + if(hx>=0) { /* x > 0 */ + if (hy<0||(ix>>20)>(iy>>52) + || ((ix>>20)==(iy>>52) + && (((((int64_t)hx)<<32)|(lx))>(hy&0x000fffffffffffffLL) + || (((((int64_t)hx)<<32)|(lx))==(hy&0x000fffffffffffffLL) + )))) { /* x > y, x -= ulp */ + if(lx==0) hx -= 1; + lx -= 1; + } else { /* x < y, x += ulp */ + lx += 1; + if(lx==0) hx += 1; + } + } else { /* x < 0 */ + if (hy>=0||(ix>>20)>(iy>>52) + || ((ix>>20)==(iy>>52) + && (((((int64_t)hx)<<32)|(lx))>(hy&0x000fffffffffffffLL) + || (((((int64_t)hx)<<32)|(lx))==(hy&0x000fffffffffffffLL) + )))) { /* x < y, x -= ulp */ + if(lx==0) hx -= 1; + lx -= 1; + } else { /* x > y, x += ulp */ + lx += 1; + if(lx==0) hx += 1; + } + } + hy = hx&0x7ff00000; + if(hy>=0x7ff00000) { + x = x+x; /* overflow */ + if (FLT_EVAL_METHOD != 0 && FLT_EVAL_METHOD != 1) + /* Force conversion to float. */ + asm ("" : "=m"(x) : "m"(x)); + return x; + } + if(hy<0x00100000) { /* underflow */ + double x2 = x*x; + if(x2!=x) { /* raise underflow flag */ + INSERT_WORDS(x2,hx,lx); + return x2; + } + } + INSERT_WORDS(x,hx,lx); + return x; +} +long_double_symbol (libm, __nexttoward, nexttoward); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c b/sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c new file mode 100644 index 0000000..a9373ff --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c @@ -0,0 +1,83 @@ +/* s_nexttowardf.c -- float version of s_nextafter.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com + * and Jakub Jelinek, jj@ultra.linux.cz. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +#include "math.h" +#include "math_private.h" +#include + +#ifdef __STDC__ + float __nexttowardf(float x, long double y) +#else + float __nexttowardf(x,y) + float x; + long double y; +#endif +{ + int32_t hx,ix; + int64_t hy,iy; + u_int64_t ly, uly; + + GET_FLOAT_WORD(hx,x); + GET_LDOUBLE_WORDS64(hy,ly,y); + ix = hx&0x7fffffff; /* |x| */ + iy = hy&0x7fffffffffffffffLL; /* |y| */ + uly = ly&0x7fffffffffffffffLL; /* |y| */ + + if((ix>0x7f800000) || /* x is nan */ + ((iy>=0x7ff0000000000000LL)&&((iy-0x7ff0000000000000LL)|uly)!=0)) + /* y is nan */ + return x+y; + if((long double) x==y) return y; /* x=y, return y */ + if(ix==0) { /* x == 0 */ + float x2; + SET_FLOAT_WORD(x,(u_int32_t)((hy>>32)&0x80000000)|1);/* return +-minsub*/ + x2 = x*x; + if(x2==x) return x2; else return x; /* raise underflow flag */ + } + if(hx>=0) { /* x > 0 */ + if(hy<0||(ix>>23)>(iy>>52)-0x380 + || ((ix>>23)==(iy>>52)-0x380 + && (ix&0x7fffff)>((hy>>29)&0x7fffff))) {/* x > y, x -= ulp */ + hx -= 1; + } else { /* x < y, x += ulp */ + hx += 1; + } + } else { /* x < 0 */ + if(hy>=0||(ix>>23)>(iy>>52)-0x380 + || ((ix>>23)==(iy>>52)-0x380 + && (ix&0x7fffff)>((hy>>29)&0x7fffff))) {/* x < y, x -= ulp */ + hx -= 1; + } else { /* x > y, x += ulp */ + hx += 1; + } + } + hy = hx&0x7f800000; + if(hy>=0x7f800000) return x+x; /* overflow */ + if(hy<0x00800000) { /* underflow */ + float x2 = x*x; + if(x2!=x) { /* raise underflow flag */ + SET_FLOAT_WORD(x2,hx); + return x2; + } + } + SET_FLOAT_WORD(x,hx); + return x; +} +long_double_symbol (libm, __nexttowardf, nexttowardf); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_remquol.c b/sysdeps/ieee754/ldbl-128ibm/s_remquol.c new file mode 100644 index 0000000..ca504a0 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_remquol.c @@ -0,0 +1,111 @@ +/* Compute remainder and a congruent to the quotient. + Copyright (C) 1997,1999,2002,2004,2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997 and + Jakub Jelinek , 1999. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include + +#include "math_private.h" +#include + + +static const long double zero = 0.0; + + +long double +__remquol (long double x, long double y, int *quo) +{ + int64_t hx,hy; + u_int64_t sx,lx,ly,qs; + int cquo; + + GET_LDOUBLE_WORDS64 (hx, lx, x); + GET_LDOUBLE_WORDS64 (hy, ly, y); + sx = hx & 0x8000000000000000ULL; + qs = sx ^ (hy & 0x8000000000000000ULL); + hy &= 0x7fffffffffffffffLL; + hx &= 0x7fffffffffffffffLL; + + /* Purge off exception values. */ + if ((hy | (ly & 0x7fffffffffffffff)) == 0) + return (x * y) / (x * y); /* y = 0 */ + if ((hx >= 0x7ff0000000000000LL) /* x not finite */ + || ((hy >= 0x7ff0000000000000LL) /* y is NaN */ + && (((hy - 0x7ff0000000000000LL) | ly) != 0))) + return (x * y) / (x * y); + + if (hy <= 0x7fbfffffffffffffLL) + x = __ieee754_fmodl (x, 8 * y); /* now x < 8y */ + + if (((hx - hy) | (lx - ly)) == 0) + { + *quo = qs ? -1 : 1; + return zero * x; + } + + x = fabsl (x); + y = fabsl (y); + cquo = 0; + + if (x >= 4 * y) + { + x -= 4 * y; + cquo += 4; + } + if (x >= 2 * y) + { + x -= 2 * y; + cquo += 2; + } + + if (hy < 0x0020000000000000LL) + { + if (x + x > y) + { + x -= y; + ++cquo; + if (x + x >= y) + { + x -= y; + ++cquo; + } + } + } + else + { + long double y_half = 0.5L * y; + if (x > y_half) + { + x -= y; + ++cquo; + if (x >= y_half) + { + x -= y; + ++cquo; + } + } + } + + *quo = qs ? -cquo : cquo; + + if (sx) + x = -x; + return x; +} +long_double_symbol (libm, __remquol, remquol); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_rintl.c b/sysdeps/ieee754/ldbl-128ibm/s_rintl.c new file mode 100644 index 0000000..51b1fea --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_rintl.c @@ -0,0 +1,119 @@ +/* Round to int long double floating-point values. + IBM extended format long double version. + Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* This has been coded in assembler because GCC makes such a mess of it + when it's coded in C. */ + +#include +#include +#include +#include + + +#ifdef __STDC__ +long double +__rintl (long double x) +#else +long double +__rintl (x) + long double x; +#endif +{ + static const long double TWO52 = 4503599627370496.0L; + union ibm_extended_long_double u; + u.d = x; + + if (fabs (u.dd[0]) < TWO52) + { + double high = u.dd[0]; + if (high > 0.0) + { + high += TWO52; + high -= TWO52; + if (high == -0.0) high = 0.0; + } + else if (high < 0.0) + { + high -= TWO52; + high += TWO52; + if (high == 0.0) high = -0.0; + } + u.dd[0] = high; + u.dd[1] = 0.0; + } + else if (fabs (u.dd[1]) < TWO52 && u.dd[1] != 0.0) + { + double high, low, tau; + /* In this case we have to round the low double and handle any + adjustment to the high double that may be caused by rounding + (up). This is complicated by the fact that the high double + may already be rounded and the low double may have the + opposite sign to compensate. */ + if (u.dd[0] > 0.0) + { + if (u.dd[1] > 0.0) + { + /* If the high/low doubles are the same sign then simply + round the low double. */ + high = u.dd[0]; + low = u.dd[1]; + } + else if (u.dd[1] < 0.0) + { + /* Else the high double is pre rounded and we need to + adjust for that. */ + + tau = nextafter (u.dd[0], 0.0); + tau = (u.dd[0] - tau) * 2.0; + high = u.dd[0] - tau; + low = u.dd[1] + tau; + } + low += TWO52; + low -= TWO52; + } + else if (u.dd[0] < 0.0) + { + if (u.dd[1] < 0.0) + { + /* If the high/low doubles are the same sign then simply + round the low double. */ + high = u.dd[0]; + low = u.dd[1]; + } + else if (u.dd[1] > 0.0) + { + /* Else the high double is pre rounded and we need to + adjust for that. */ + tau = nextafter (u.dd[0], 0.0); + tau = (u.dd[0] - tau) * 2.0; + high = u.dd[0] - tau; + low = u.dd[1] + tau; + } + low = TWO52 - low; + low = -(low - TWO52); + } + u.dd[0] = high + low; + u.dd[1] = high - u.dd[0] + low; + } + + return u.d; +} + +long_double_symbol (libm, __rintl, rintl); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_roundl.c b/sysdeps/ieee754/ldbl-128ibm/s_roundl.c new file mode 100644 index 0000000..7fe84b8 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_roundl.c @@ -0,0 +1,120 @@ +/* Round to int long double floating-point values. + IBM extended format long double version. + Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* This has been coded in assembler because GCC makes such a mess of it + when it's coded in C. */ + +#include +#include +#include +#include +#include + + +#ifdef __STDC__ +long double +__roundl (long double x) +#else +long double +__roundl (x) + long double x; +#endif +{ + static const double TWO52 = 4503599627370496.0; + static const double HALF = 0.5; + int mode = fegetround(); + union ibm_extended_long_double u; + u.d = x; + + if (fabs (u.dd[0]) < TWO52) + { + fesetround(FE_TOWARDZERO); + if (u.dd[0] > 0.0) + { + u.dd[0] += HALF; + u.dd[0] += TWO52; + u.dd[0] -= TWO52; + } + else if (u.dd[0] < 0.0) + { + u.dd[0] = TWO52 - (u.dd[0] - HALF); + u.dd[0] = -(u.dd[0] - TWO52); + } + u.dd[1] = 0.0; + fesetround(mode); + } + else if (fabs (u.dd[1]) < TWO52 && u.dd[1] != 0.0) + { + double high, low; + /* In this case we have to round the low double and handle any + adjustment to the high double that may be caused by rounding + (up). This is complicated by the fact that the high double + may already be rounded and the low double may have the + opposite sign to compensate. */ + if (u.dd[0] > 0.0) + { + if (u.dd[1] > 0.0) + { + /* If the high/low doubles are the same sign then simply + round the low double. */ + high = u.dd[0]; + low = u.dd[1]; + } + else if (u.dd[1] < 0.0) + { + /* Else the high double is pre rounded and we need to + adjust for that. */ + high = nextafter (u.dd[0], 0.0); + low = u.dd[1] + (u.dd[0] - high); + } + fesetround(FE_TOWARDZERO); + low += HALF; + low += TWO52; + low -= TWO52; + } + else if (u.dd[0] < 0.0) + { + if (u.dd[1] < 0.0) + { + /* If the high/low doubles are the same sign then simply + round the low double. */ + high = u.dd[0]; + low = u.dd[1]; + } + else if (u.dd[1] > 0.0) + { + /* Else the high double is pre rounded and we need to + adjust for that. */ + high = nextafter (u.dd[0], 0.0); + low = u.dd[1] + (u.dd[0] - high); + } + fesetround(FE_TOWARDZERO); + low -= HALF; + low = TWO52 - low; + low = -(low - TWO52); + } + fesetround(mode); + u.dd[0] = high + low; + u.dd[1] = high - u.dd[0] + low; + } + return u.d; +} + +long_double_symbol (libm, __roundl, roundl); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_scalblnl.c b/sysdeps/ieee754/ldbl-128ibm/s_scalblnl.c new file mode 100644 index 0000000..3a1ba07 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_scalblnl.c @@ -0,0 +1,105 @@ +/* s_scalblnl.c -- long double version of s_scalbln.c. + * Conversion to IEEE quad long double by Jakub Jelinek, jj@ultra.linux.cz. + */ + +/* @(#)s_scalbln.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * scalblnl (long double x, long int n) + * scalblnl(x,n) returns x* 2**n computed by exponent + * manipulation rather than by actually performing an + * exponentiation or a multiplication. + */ + +#include "math.h" +#include "math_private.h" +#include + +#ifdef __STDC__ +static const long double +#else +static long double +#endif +twolm54 = 5.55111512312578270212e-17, /* 0x3C90000000000000, 0 */ +huge = 1.0E+300L, +tiny = 1.0E-300L; +#ifdef __STDC__ +static const double +#else +static double +#endif +two54 = 1.80143985094819840000e+16, /* 0x4350000000000000 */ +twom54 = 5.55111512312578270212e-17; /* 0x3C90000000000000 */ + +#ifdef __STDC__ + long double __scalblnl (long double x, long int n) +#else + long double __scalblnl (x,n) + long double x; long int n; +#endif +{ + int64_t k,l,hx,lx; + union { int64_t i; double d; } u; + GET_LDOUBLE_WORDS64(hx,lx,x); + k = (hx>>52)&0x7ff; /* extract exponent */ + l = (lx>>52)&0x7ff; + if (k==0) { /* 0 or subnormal x */ + if (((hx|lx)&0x7fffffffffffffffULL)==0) return x; /* +-0 */ + u.i = hx; + u.d *= two54; + hx = u.i; + k = ((hx>>52)&0x7ff) - 54; + } + else if (k==0x7ff) return x+x; /* NaN or Inf */ + k = k+n; + if (n> 50000 || k > 0x7fe) + return huge*__copysignl(huge,x); /* overflow */ + if (n< -50000) return tiny*__copysignl(tiny,x); /*underflow */ + if (k > 0) { /* normal result */ + hx = (hx&0x800fffffffffffffULL)|(k<<52); + if ((lx & 0x7fffffffffffffffULL) == 0) { /* low part +-0 */ + SET_LDOUBLE_WORDS64(x,hx,lx); + return x; + } + if (l == 0) { /* low part subnormal */ + u.i = lx; + u.d *= two54; + lx = u.i; + l = ((lx>>52)&0x7ff) - 54; + } + l = l + n; + if (l > 0) + lx = (lx&0x800fffffffffffffULL)|(l<<52); + else if (l <= -54) + lx = (lx&0x8000000000000000ULL); + else { + l += 54; + u.i = (lx&0x800fffffffffffffULL)|(l<<52); + u.d *= twom54; + lx = u.i; + } + SET_LDOUBLE_WORDS64(x,hx,lx); + return x; + } + if (k <= -54) + return tiny*__copysignl(tiny,x); /*underflow*/ + k += 54; /* subnormal result */ + lx &= 0x8000000000000000ULL; + SET_LDOUBLE_WORDS64(x,(hx&0x800fffffffffffffULL)|(k<<52),lx); + return x*twolm54; +} +long_double_symbol (libm, __scalblnl, scalblnl); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_scalbnl.c b/sysdeps/ieee754/ldbl-128ibm/s_scalbnl.c new file mode 100644 index 0000000..50bd8cb --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_scalbnl.c @@ -0,0 +1,109 @@ +/* s_scalbnl.c -- long double version of s_scalbn.c. + * Conversion to IEEE quad long double by Jakub Jelinek, jj@ultra.linux.cz. + */ + +/* @(#)s_scalbn.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * scalbnl (long double x, int n) + * scalbnl(x,n) returns x* 2**n computed by exponent + * manipulation rather than by actually performing an + * exponentiation or a multiplication. + */ + +#include "math.h" +#include "math_private.h" +#include + +#ifdef __STDC__ +static const long double +#else +static long double +#endif +twolm54 = 5.55111512312578270212e-17, /* 0x3C90000000000000, 0 */ +huge = 1.0E+300L, +tiny = 1.0E-300L; +#ifdef __STDC__ +static const double +#else +static double +#endif +two54 = 1.80143985094819840000e+16, /* 0x4350000000000000 */ +twom54 = 5.55111512312578270212e-17; /* 0x3C90000000000000 */ + +#ifdef __STDC__ + long double __scalbnl (long double x, int n) +#else + long double __scalbnl (x,n) + long double x; int n; +#endif +{ + int64_t k,l,hx,lx; + union { int64_t i; double d; } u; + GET_LDOUBLE_WORDS64(hx,lx,x); + k = (hx>>52)&0x7ff; /* extract exponent */ + l = (lx>>52)&0x7ff; + if (k==0) { /* 0 or subnormal x */ + if (((hx|lx)&0x7fffffffffffffffULL)==0) return x; /* +-0 */ + u.i = hx; + u.d *= two54; + hx = u.i; + k = ((hx>>52)&0x7ff) - 54; + } + else if (k==0x7ff) return x+x; /* NaN or Inf */ + k = k+n; + if (n> 50000 || k > 0x7fe) + return huge*__copysignl(huge,x); /* overflow */ + if (n< -50000) return tiny*__copysignl(tiny,x); /*underflow */ + if (k > 0) { /* normal result */ + hx = (hx&0x800fffffffffffffULL)|(k<<52); + if ((lx & 0x7fffffffffffffffULL) == 0) { /* low part +-0 */ + SET_LDOUBLE_WORDS64(x,hx,lx); + return x; + } + if (l == 0) { /* low part subnormal */ + u.i = lx; + u.d *= two54; + lx = u.i; + l = ((lx>>52)&0x7ff) - 54; + } + l = l + n; + if (l > 0) + lx = (lx&0x800fffffffffffffULL)|(l<<52); + else if (l <= -54) + lx = (lx&0x8000000000000000ULL); + else { + l += 54; + u.i = (lx&0x800fffffffffffffULL)|(l<<52); + u.d *= twom54; + lx = u.i; + } + SET_LDOUBLE_WORDS64(x,hx,lx); + return x; + } + if (k <= -54) + return tiny*__copysignl(tiny,x); /*underflow*/ + k += 54; /* subnormal result */ + lx &= 0x8000000000000000ULL; + SET_LDOUBLE_WORDS64(x,(hx&0x800fffffffffffffULL)|(k<<52),lx); + return x*twolm54; +} +#ifdef IS_IN_libm +long_double_symbol (libm, __scalbnl, scalbnl); +#else +long_double_symbol (libc, __scalbnl, scalbnl); +#endif diff --git a/sysdeps/ieee754/ldbl-128ibm/s_signbitl.c b/sysdeps/ieee754/ldbl-128ibm/s_signbitl.c new file mode 100644 index 0000000..b428546 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_signbitl.c @@ -0,0 +1,37 @@ +/* Return nonzero value if number is negative. + Copyright (C) 1997,1999,2004,2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include "math_private.h" +#include + +int +___signbitl (long double x) +{ + int64_t e; + + GET_LDOUBLE_MSW64 (e, x); + return e < 0; +} +#ifdef IS_IN_libm +long_double_symbol (libm, ___signbitl, __signbitl); +#else +long_double_symbol (libc, ___signbitl, __signbitl); +#endif diff --git a/sysdeps/ieee754/ldbl-128ibm/s_sincosl.c b/sysdeps/ieee754/ldbl-128ibm/s_sincosl.c new file mode 100644 index 0000000..1d3d7a4 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_sincosl.c @@ -0,0 +1,72 @@ +/* Compute sine and cosine of argument. + Copyright (C) 1997,1999,2004,2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997 and + Jakub Jelinek . + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include + +#include "math_private.h" +#include + +void +__sincosl (long double x, long double *sinx, long double *cosx) +{ + int64_t ix; + + /* High word of x. */ + GET_LDOUBLE_MSW64 (ix, x); + + /* |x| ~< pi/4 */ + ix &= 0x7fffffffffffffffLL; + if (ix <= 0x3fe921fb54442d10LL) + __kernel_sincosl (x, 0.0L, sinx, cosx, 0); + else if (ix >= 0x7ff0000000000000LL) + { + /* sin(Inf or NaN) is NaN */ + *sinx = *cosx = x - x; + } + else + { + /* Argument reduction needed. */ + long double y[2]; + int n; + + n = __ieee754_rem_pio2l (x, y); + switch (n & 3) + { + case 0: + __kernel_sincosl (y[0], y[1], sinx, cosx, 1); + break; + case 1: + __kernel_sincosl (y[0], y[1], cosx, sinx, 1); + *cosx = -*cosx; + break; + case 2: + __kernel_sincosl (y[0], y[1], sinx, cosx, 1); + *sinx = -*sinx; + *cosx = -*cosx; + break; + default: + __kernel_sincosl (y[0], y[1], cosx, sinx, 1); + *sinx = -*sinx; + break; + } + } +} +long_double_symbol (libm, __sincosl, sincosl); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_sinl.c b/sysdeps/ieee754/ldbl-128ibm/s_sinl.c new file mode 100644 index 0000000..8cc592c --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_sinl.c @@ -0,0 +1,84 @@ +/* s_sinl.c -- long double version of s_sin.c. + * Conversion to long double by Jakub Jelinek, jj@ultra.linux.cz. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* sinl(x) + * Return sine function of x. + * + * kernel function: + * __kernel_sinl ... sine function on [-pi/4,pi/4] + * __kernel_cosl ... cose function on [-pi/4,pi/4] + * __ieee754_rem_pio2l ... argument reduction routine + * + * Method. + * Let S,C and T denote the sin, cos and tan respectively on + * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 + * in [-pi/4 , +pi/4], and let n = k mod 4. + * We have + * + * n sin(x) cos(x) tan(x) + * ---------------------------------------------------------- + * 0 S C T + * 1 C -S -1/T + * 2 -S -C T + * 3 -C S -1/T + * ---------------------------------------------------------- + * + * Special cases: + * Let trig be any of sin, cos, or tan. + * trig(+-INF) is NaN, with signals; + * trig(NaN) is that NaN; + * + * Accuracy: + * TRIG(x) returns trig(x) nearly rounded + */ + +#include "math.h" +#include "math_private.h" +#include + +#ifdef __STDC__ + long double __sinl(long double x) +#else + long double __sinl(x) + long double x; +#endif +{ + long double y[2],z=0.0L; + int64_t n, ix; + + /* High word of x. */ + GET_LDOUBLE_MSW64(ix,x); + + /* |x| ~< pi/4 */ + ix &= 0x7fffffffffffffffLL; + if(ix <= 0x3fe921fb54442d10LL) + return __kernel_sinl(x,z,0); + + /* sin(Inf or NaN) is NaN */ + else if (ix>=0x7ff0000000000000LL) return x-x; + + /* argument reduction needed */ + else { + n = __ieee754_rem_pio2l(x,y); + switch(n&3) { + case 0: return __kernel_sinl(y[0],y[1],1); + case 1: return __kernel_cosl(y[0],y[1]); + case 2: return -__kernel_sinl(y[0],y[1],1); + default: + return -__kernel_cosl(y[0],y[1]); + } + } +} +long_double_symbol (libm, __sinl, sinl); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_tanhl.c b/sysdeps/ieee754/ldbl-128ibm/s_tanhl.c new file mode 100644 index 0000000..851ca12 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_tanhl.c @@ -0,0 +1,90 @@ +/* @(#)s_tanh.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: s_tanh.c,v 1.7 1995/05/10 20:48:22 jtc Exp $"; +#endif + +/* Tanh(x) + * Return the Hyperbolic Tangent of x + * + * Method : + * x -x + * e - e + * 0. tanh(x) is defined to be ----------- + * x -x + * e + e + * 1. reduce x to non-negative by tanh(-x) = -tanh(x). + * 2. 0 <= x <= 2**-57 : tanh(x) := x*(one+x) + * -t + * 2**-57 < x <= 1 : tanh(x) := -----; t = expm1(-2x) + * t + 2 + * 2 + * 1 <= x <= 22.0 : tanh(x) := 1- ----- ; t=expm1(2x) + * t + 2 + * 22.0 < x <= INF : tanh(x) := 1. + * + * Special cases: + * tanh(NaN) is NaN; + * only tanh(0)=0 is exact for finite argument. + */ + +#include "math.h" +#include "math_private.h" +#include + +#ifdef __STDC__ +static const long double one=1.0L, two=2.0L, tiny = 1.0e-300L; +#else +static long double one=1.0L, two=2.0L, tiny = 1.0e-300L; +#endif + +#ifdef __STDC__ + long double __tanhl(long double x) +#else + long double __tanhl(x) + long double x; +#endif +{ + long double t,z; + int64_t jx,ix,lx; + + /* High word of |x|. */ + GET_LDOUBLE_WORDS64(jx,lx,x); + ix = jx&0x7fffffffffffffffLL; + + /* x is INF or NaN */ + if(ix>=0x7ff0000000000000LL) { + if (jx>=0) return one/x+one; /* tanh(+-inf)=+-1 */ + else return one/x-one; /* tanh(NaN) = NaN */ + } + + /* |x| < 22 */ + if (ix < 0x4036000000000000LL) { /* |x|<22 */ + if ((ix | (lx&0x7fffffffffffffffLL)) == 0) + return x; /* x == +-0 */ + if (ix<0x3c60000000000000LL) /* |x|<2**-57 */ + return x*(one+x); /* tanh(small) = small */ + if (ix>=0x3ff0000000000000LL) { /* |x|>=1 */ + t = __expm1l(two*fabsl(x)); + z = one - two/(t+two); + } else { + t = __expm1l(-two*fabsl(x)); + z= -t/(t+two); + } + /* |x| > 22, return +-1 */ + } else { + z = one - tiny; /* raised inexact flag */ + } + return (jx>=0)? z: -z; +} +long_double_symbol (libm, __tanhl, tanhl); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_tanl.c b/sysdeps/ieee754/ldbl-128ibm/s_tanl.c new file mode 100644 index 0000000..ea5a7f0 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_tanl.c @@ -0,0 +1,78 @@ +/* s_tanl.c -- long double version of s_tan.c. + * Conversion to IEEE quad long double by Jakub Jelinek, jj@ultra.linux.cz. + */ + +/* @(#)s_tan.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* tanl(x) + * Return tangent function of x. + * + * kernel function: + * __kernel_tanl ... tangent function on [-pi/4,pi/4] + * __ieee754_rem_pio2l ... argument reduction routine + * + * Method. + * Let S,C and T denote the sin, cos and tan respectively on + * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 + * in [-pi/4 , +pi/4], and let n = k mod 4. + * We have + * + * n sin(x) cos(x) tan(x) + * ---------------------------------------------------------- + * 0 S C T + * 1 C -S -1/T + * 2 -S -C T + * 3 -C S -1/T + * ---------------------------------------------------------- + * + * Special cases: + * Let trig be any of sin, cos, or tan. + * trig(+-INF) is NaN, with signals; + * trig(NaN) is that NaN; + * + * Accuracy: + * TRIG(x) returns trig(x) nearly rounded + */ + +#include "math.h" +#include "math_private.h" +#include + +#ifdef __STDC__ + long double __tanl(long double x) +#else + long double __tanl(x) + long double x; +#endif +{ + long double y[2],z=0.0L; + int64_t n, ix; + + /* High word of x. */ + GET_LDOUBLE_MSW64(ix,x); + + /* |x| ~< pi/4 */ + ix &= 0x7fffffffffffffffLL; + if(ix <= 0x3fe921fb54442d10LL) return __kernel_tanl(x,z,1); + + /* tanl(Inf or NaN) is NaN */ + else if (ix>=0x7ff0000000000000LL) return x-x; /* NaN */ + + /* argument reduction needed */ + else { + n = __ieee754_rem_pio2l(x,y); + return __kernel_tanl(y[0],y[1],1-((n&1)<<1)); /* 1 -- n even + -1 -- n odd */ + } +} +long_double_symbol (libm, __tanl, tanl); diff --git a/sysdeps/ieee754/ldbl-128ibm/s_truncl.c b/sysdeps/ieee754/ldbl-128ibm/s_truncl.c new file mode 100644 index 0000000..14544af --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/s_truncl.c @@ -0,0 +1,119 @@ +/* Truncate (toward zero) long double floating-point values. + IBM extended format long double version. + Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* This has been coded in assembler because GCC makes such a mess of it + when it's coded in C. */ + +#include +#include +#include +#include +#include + + +#ifdef __STDC__ +long double +__truncl (long double x) +#else +long double +__truncl (x) + long double x; +#endif +{ + static const double TWO52 = 4503599627370496.0L; + int mode = fegetround(); + union ibm_extended_long_double u; + + u.d = x; + + if (fabs (u.dd[0]) < TWO52) + { + fesetround(FE_TOWARDZERO); + if (u.dd[0] > 0.0) + { + u.dd[0] += TWO52; + u.dd[0] -= TWO52; + } + else if (u.dd[0] < 0.0) + { + u.dd[0] = TWO52 - u.dd[0]; + u.dd[0] = -(u.dd[0] - TWO52); + } + u.dd[1] = 0.0; + fesetround(mode); + } + else if (fabs (u.dd[1]) < TWO52 && u.dd[1] != 0.0) + { + double high, low; + /* In this case we have to round the low double and handle any + adjustment to the high double that may be caused by rounding + (up). This is complicated by the fact that the high double + may already be rounded and the low double may have the + opposite sign to compensate. */ + if (u.dd[0] > 0.0) + { + if (u.dd[1] > 0.0) + { + /* If the high/low doubles are the same sign then simply + round the low double. */ + high = u.dd[0]; + low = u.dd[1]; + } + else if (u.dd[1] < 0.0) + { + /* Else the high double is pre rounded and we need to + adjust for that. */ + high = nextafter (u.dd[0], 0.0); + low = u.dd[1] + (u.dd[0] - high); + } + fesetround(FE_TOWARDZERO); + low += TWO52; + low -= TWO52; + fesetround(mode); + } + else if (u.dd[0] < 0.0) + { + if (u.dd[1] < 0.0) + { + /* If the high/low doubles are the same sign then simply + round the low double. */ + high = u.dd[0]; + low = u.dd[1]; + } + else if (u.dd[1] > 0.0) + { + /* Else the high double is pre rounded and we need to + adjust for that. */ + high = nextafter (u.dd[0], 0.0); + low = u.dd[1] + (u.dd[0] - high); + } + fesetround(FE_TOWARDZERO); + low = TWO52 - low; + low = -(low - TWO52); + fesetround(mode); + } + u.dd[0] = high + low; + u.dd[1] = high - u.dd[0] + low; + } + + return u.d; +} + +long_double_symbol (libm, __truncl, truncl); diff --git a/sysdeps/ieee754/ldbl-128ibm/strtold_l.c b/sysdeps/ieee754/ldbl-128ibm/strtold_l.c new file mode 100644 index 0000000..d558b00 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/strtold_l.c @@ -0,0 +1,63 @@ +/* Copyright (C) 1999, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include +#include + +/* The actual implementation for all floating point sizes is in strtod.c. + These macros tell it to produce the `long double' version, `strtold'. */ + +#define FLOAT long double +#define FLT LDBL +#ifdef USE_WIDE_CHAR +extern long double ____new_wcstold_l (const wchar_t *, wchar_t **, __locale_t); +# define STRTOF __new_wcstold_l +# define __STRTOF ____new_wcstold_l +# define ____STRTOF_INTERNAL ____wcstold_l_internal +#else +extern long double ____new_strtold_l (const char *, char **, __locale_t); +# define STRTOF __new_strtold_l +# define __STRTOF ____new_strtold_l +# define ____STRTOF_INTERNAL ____strtold_l_internal +#endif +#define MPN2FLOAT __mpn_construct_long_double +#define FLOAT_HUGE_VAL HUGE_VALL +# define SET_MANTISSA(flt, mant) \ + do { union ibm_extended_long_double u; \ + u.d = (flt); \ + if ((mant & 0xfffffffffffffULL) == 0) \ + mant = 0x8000000000000ULL; \ + u.ieee.mantissa0 = ((mant) >> 32) & 0xfffff; \ + u.ieee.mantissa1 = (mant) & 0xffffffff; \ + (flt) = u.d; \ + } while (0) + +#include + +#ifdef __LONG_DOUBLE_MATH_OPTIONAL +# include +# ifdef USE_WIDE_CHAR +long_double_symbol (libc, __new_wcstold_l, wcstold_l); +long_double_symbol (libc, ____new_wcstold_l, __wcstold_l); +# else +long_double_symbol (libc, __new_strtold_l, strtold_l); +long_double_symbol (libc, ____new_strtold_l, __strtold_l); +# endif +#endif diff --git a/sysdeps/ieee754/ldbl-128ibm/t_sincosl.c b/sysdeps/ieee754/ldbl-128ibm/t_sincosl.c new file mode 100644 index 0000000..4c92a0d --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/t_sincosl.c @@ -0,0 +1,694 @@ +/* Quad-precision floating point sine and cosine tables. + Copyright (C) 1999,2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* For 0.1484375 + n/128.0, n=0..82 this table contains + first 113 bits of cosine, then at least 113 additional + bits and the same for sine. + 0.1484375+82.0/128.0 is the smallest number among above defined numbers + larger than pi/4. + Computed using gmp. + */ + +const long double __sincosl_table[] = { + +/* x = 1.48437500000000000000000000000000000e-01L 3ffc3000000000000000000000000000 */ +/* cos(x) = 0.fd2f5320e1b790209b4dda2f98 f79caaa7b873aff1014b0fbc52 43766d03cb006bc837c4358 */ + 0x0.fd2f5320e1b790209b4dda2f98p0L, + 0x0.f79caaa7b873aff1014b0fbc52p-104L, +/* sin(x) = 0.25dc50bc95711d0d9787d108fd 438cf5959ee0bfb7a1e36e8b1a 112968f356657420e9cc9ea */ + 0x0.25dc50bc95711d0d9787d108fdp0L, + 0x0.438cf5959ee0bfb7a1e36e8b1ap-104L, + +/* x = 1.56250000000000000000000000000000000e-01 3ffc4000000000000000000000000000 */ +/* cos(x) = 0.fce1a053e621438b6d60c76e8c 45bf0a9dc71aa16f922acc10e9 5144ec796a249813c9cb649 */ + 0x0.fce1a053e621438b6d60c76e8cp0L, + 0x0.45bf0a9dc71aa16f922acc10e9p-104L, +/* sin(x) = 0.27d66258bacd96a3eb335b365c 87d59438c5142bb56a489e9b8d b9d36234ffdebb6bdc22d8e */ + 0x0.27d66258bacd96a3eb335b365cp0L, + 0x0.87d59438c5142bb56a489e9b8dp-104L, + +/* x = 1.64062500000000000000000000000000000e-01 3ffc5000000000000000000000000000 */ +/* cos(x) = 0.fc8ffa01ba6807417e05962b0d 9fdf1fddb0cc4c07d22e19e080 19bffa50a6c7acdb40307a3 */ + 0x0.fc8ffa01ba6807417e05962b0dp0L, + 0x0.9fdf1fddb0cc4c07d22e19e080p-104L, +/* sin(x) = 0.29cfd49b8be4f665276cab01cb f0426934906c3dd105473b226e 410b1450f62e53ff7c6cce1 */ + 0x0.29cfd49b8be4f665276cab01cbp0L, + 0x0.f0426934906c3dd105473b226ep-104L, + +/* x = 1.71875000000000000000000000000000000e-01 3ffc6000000000000000000000000000 */ +/* cos(x) = 0.fc3a6170f767ac735d63d99a9d 439e1db5e59d3ef153a4265d58 55850ed82b536bf361b80e3 */ + 0x0.fc3a6170f767ac735d63d99a9dp0L, + 0x0.439e1db5e59d3ef153a4265d58p-104L, +/* sin(x) = 0.2bc89f9f424de5485de7ce03b2 514952b9faf5648c3244d4736f eb95dbb9da49f3b58a9253b */ + 0x0.2bc89f9f424de5485de7ce03b2p0L, + 0x0.514952b9faf5648c3244d4736fp-104L, + +/* x = 1.79687500000000000000000000000000000e-01 3ffc7000000000000000000000000000 */ +/* cos(x) = 0.fbe0d7f7fef11e70aa43b8abf4 f6a457cea20c8f3f676b47781f 9821bbe9ce04b3c7b981c0b */ + 0x0.fbe0d7f7fef11e70aa43b8abf4p0L, + 0x0.f6a457cea20c8f3f676b47781fp-104L, +/* sin(x) = 0.2dc0bb80b49a97ffb34e8dd1f8 db9df7af47ed2dcf58b12c8e78 27e048cae929da02c04ecac */ + 0x0.2dc0bb80b49a97ffb34e8dd1f8p0L, + 0x0.db9df7af47ed2dcf58b12c8e78p-104L, + +/* x = 1.87500000000000000000000000000000000e-01 3ffc8000000000000000000000000000 */ +/* cos(x) = 0.fb835efcf670dd2ce6fe792469 7eea13ea358867e9cdb3899b78 3f4f9f43aa5626e8b67b3bc */ + 0x0.fb835efcf670dd2ce6fe792469p0L, + 0x0.7eea13ea358867e9cdb3899b78p-104L, +/* sin(x) = 0.2fb8205f75e56a2b56a1c4792f 856258769af396e0189ef72c05 e4df59a6b00e4b44a6ea515 */ + 0x0.2fb8205f75e56a2b56a1c4792fp0L, + 0x0.856258769af396e0189ef72c05p-104L, + +/* x = 1.95312500000000000000000000000000000e-01 3ffc9000000000000000000000000000 */ +/* cos(x) = 0.fb21f7f5c156696b00ac1fe28a c5fd76674a92b4df80d9c8a46c 684399005deccc41386257c */ + 0x0.fb21f7f5c156696b00ac1fe28ap0L, + 0x0.c5fd76674a92b4df80d9c8a46cp-104L, +/* sin(x) = 0.31aec65df552876f82ece9a235 6713246eba6799983d7011b0b3 698d6e1da919c15d57c30c1 */ + 0x0.31aec65df552876f82ece9a235p0L, + 0x0.6713246eba6799983d7011b0b3p-104L, + +/* x = 2.03125000000000000000000000000000000e-01 3ffca000000000000000000000000000 */ +/* cos(x) = 0.fabca467fb3cb8f1d069f01d8e a33ade5bfd68296ecd1cc9f7b7 609bbcf3676e726c3301334 */ + 0x0.fabca467fb3cb8f1d069f01d8ep0L, + 0x0.a33ade5bfd68296ecd1cc9f7b7p-104L, +/* sin(x) = 0.33a4a5a19d86246710f602c44d f4fa513f4639ce938477aeeabb 82e8e0a7ed583a188879fd4 */ + 0x0.33a4a5a19d86246710f602c44dp0L, + 0x0.f4fa513f4639ce938477aeeabbp-104L, + +/* x = 2.10937500000000000000000000000000000e-01 3ffcb000000000000000000000000000 */ +/* cos(x) = 0.fa5365e8f1d3ca27be1db5d76a e64d983d7470a4ab0f4ccf65a2 b8c67a380df949953a09bc1 */ + 0x0.fa5365e8f1d3ca27be1db5d76ap0L, + 0x0.e64d983d7470a4ab0f4ccf65a2p-104L, +/* sin(x) = 0.3599b652f40ec999df12a0a4c8 561de159c98d4e54555de518b9 7f48886f715d8df5f4f093e */ + 0x0.3599b652f40ec999df12a0a4c8p0L, + 0x0.561de159c98d4e54555de518b9p-104L, + +/* x = 2.18750000000000000000000000000000000e-01 3ffcc000000000000000000000000000 */ +/* cos(x) = 0.f9e63e1d9e8b6f6f2e296bae5b 5ed9c11fd7fa2fe11e09fc7bde 901abed24b6365e72f7db4e */ + 0x0.f9e63e1d9e8b6f6f2e296bae5bp0L, + 0x0.5ed9c11fd7fa2fe11e09fc7bdep-104L, +/* sin(x) = 0.378df09db8c332ce0d2b53d865 582e4526ea336c768f68c32b49 6c6d11c1cd241bb9f1da523 */ + 0x0.378df09db8c332ce0d2b53d865p0L, + 0x0.582e4526ea336c768f68c32b49p-104L, + +/* x = 2.26562500000000000000000000000000000e-01 3ffcd000000000000000000000000000 */ +/* cos(x) = 0.f9752eba9fff6b98842beadab0 54a932fb0f8d5b875ae63d6b22 88d09b148921aeb6e52f61b */ + 0x0.f9752eba9fff6b98842beadab0p0L, + 0x0.54a932fb0f8d5b875ae63d6b22p-104L, +/* sin(x) = 0.39814cb10513453cb97b21bc1c a6a337b150c21a675ab85503bc 09a436a10ab1473934e20c8 */ + 0x0.39814cb10513453cb97b21bc1cp0L, + 0x0.a6a337b150c21a675ab85503bcp-104L, + +/* x = 2.34375000000000000000000000000000000e-01 3ffce000000000000000000000000000 */ +/* cos(x) = 0.f90039843324f9b940416c1984 b6cbed1fc733d97354d4265788 a86150493ce657cae032674 */ + 0x0.f90039843324f9b940416c1984p0L, + 0x0.b6cbed1fc733d97354d4265788p-104L, +/* sin(x) = 0.3b73c2bf6b4b9f668ef9499c81 f0d965087f1753fa64b086e58c b8470515c18c1412f8c2e02 */ + 0x0.3b73c2bf6b4b9f668ef9499c81p0L, + 0x0.f0d965087f1753fa64b086e58cp-104L, + +/* x = 2.42187500000000000000000000000000000e-01 3ffcf000000000000000000000000000 */ +/* cos(x) = 0.f887604e2c39dbb20e4ec58250 59a789ffc95b275ad9954078ba 8a28d3fcfe9cc2c1d49697b */ + 0x0.f887604e2c39dbb20e4ec58250p0L, + 0x0.59a789ffc95b275ad9954078bap-104L, +/* sin(x) = 0.3d654aff15cb457a0fca854698 aba33039a8a40626609204472d 9d40309b626eccc6dff0ffa */ + 0x0.3d654aff15cb457a0fca854698p0L, + 0x0.aba33039a8a40626609204472dp-104L, + +/* x = 2.50000000000000000000000000000000000e-01 3ffd0000000000000000000000000000 */ +/* cos(x) = 0.f80aa4fbef750ba783d33cb95f 94f8a41426dbe79edc4a023ef9 ec13c944551c0795b84fee1 */ + 0x0.f80aa4fbef750ba783d33cb95fp0L, + 0x0.94f8a41426dbe79edc4a023ef9p-104L, +/* sin(x) = 0.3f55dda9e62aed7513bd7b8e6a 3d1635dd5676648d7db525898d 7086af9330f03c7f285442a */ + 0x0.3f55dda9e62aed7513bd7b8e6ap0L, + 0x0.3d1635dd5676648d7db525898dp-104L, + +/* x = 2.57812500000000000000000000000000000e-01 3ffd0800000000000000000000000000 */ +/* cos(x) = 0.f78a098069792daabc9ee42591 b7c5a68cb1ab822aeb446b3311 b4ba5371b8970e2c1547ad7 */ + 0x0.f78a098069792daabc9ee42591p0L, + 0x0.b7c5a68cb1ab822aeb446b3311p-104L, +/* sin(x) = 0.414572fd94556e6473d6202713 88dd47c0ba050cdb5270112e3e 370e8c4705ae006426fb5d5 */ + 0x0.414572fd94556e6473d6202713p0L, + 0x0.88dd47c0ba050cdb5270112e3ep-104L, + +/* x = 2.65625000000000000000000000000000000e-01 3ffd1000000000000000000000000000 */ +/* cos(x) = 0.f7058fde0788dfc805b8fe8878 9e4f4253e3c50afe8b22f41159 620ab5940ff7df9557c0d1f */ + 0x0.f7058fde0788dfc805b8fe8878p0L, + 0x0.9e4f4253e3c50afe8b22f41159p-104L, +/* sin(x) = 0.4334033bcd90d6604f5f36c1d4 b84451a87150438275b77470b5 0e5b968fa7962b5ffb379b7 */ + 0x0.4334033bcd90d6604f5f36c1d4p0L, + 0x0.b84451a87150438275b77470b5p-104L, + +/* x = 2.73437500000000000000000000000000000e-01 3ffd1800000000000000000000000000 */ +/* cos(x) = 0.f67d3a26af7d07aa4bd6d42af8 c0067fefb96d5b46c031eff536 27f215ea3242edc3f2e13eb */ + 0x0.f67d3a26af7d07aa4bd6d42af8p0L, + 0x0.c0067fefb96d5b46c031eff536p-104L, +/* sin(x) = 0.452186aa5377ab20bbf2524f52 e3a06a969f47166ab88cf88c11 1ad12c55941021ef3317a1a */ + 0x0.452186aa5377ab20bbf2524f52p0L, + 0x0.e3a06a969f47166ab88cf88c11p-104L, + +/* x = 2.81250000000000000000000000000000000e-01 3ffd2000000000000000000000000000 */ +/* cos(x) = 0.f5f10a7bb77d3dfa0c1da8b578 42783280d01ce3c0f82bae3b9d 623c168d2e7c29977994451 */ + 0x0.f5f10a7bb77d3dfa0c1da8b578p0L, + 0x0.42783280d01ce3c0f82bae3b9dp-104L, +/* sin(x) = 0.470df5931ae1d946076fe0dcff 47fe31bb2ede618ebc607821f8 462b639e1f4298b5ae87fd3 */ + 0x0.470df5931ae1d946076fe0dcffp0L, + 0x0.47fe31bb2ede618ebc607821f8p-104L, + +/* x = 2.89062500000000000000000000000000000e-01 3ffd2800000000000000000000000000 */ +/* cos(x) = 0.f561030ddd7a78960ea9f4a32c 6521554995667f5547bafee9ec 48b3155cdb0f7fd00509713 */ + 0x0.f561030ddd7a78960ea9f4a32cp0L, + 0x0.6521554995667f5547bafee9ecp-104L, +/* sin(x) = 0.48f948446abcd6b0f7fccb100e 7a1b26eccad880b0d24b59948c 7cdd49514d44b933e6985c2 */ + 0x0.48f948446abcd6b0f7fccb100ep0L, + 0x0.7a1b26eccad880b0d24b59948cp-104L, + +/* x = 2.96875000000000000000000000000000000e-01 3ffd3000000000000000000000000000 */ +/* cos(x) = 0.f4cd261d3e6c15bb369c875863 0d2ac00b7ace2a51c0631bfeb3 9ed158ba924cc91e259c195 */ + 0x0.f4cd261d3e6c15bb369c875863p0L, + 0x0.0d2ac00b7ace2a51c0631bfeb3p-104L, +/* sin(x) = 0.4ae37710fad27c8aa9c4cf96c0 3519b9ce07dc08a1471775499f 05c29f86190aaebaeb9716e */ + 0x0.4ae37710fad27c8aa9c4cf96c0p0L, + 0x0.3519b9ce07dc08a1471775499fp-104L, + +/* x = 3.04687500000000000000000000000000000e-01 3ffd3800000000000000000000000000 */ +/* cos(x) = 0.f43575f94d4f6b272f5fb76b14 d2a64ab52df1ee8ddf7c651034 e5b2889305a9ea9015d758a */ + 0x0.f43575f94d4f6b272f5fb76b14p0L, + 0x0.d2a64ab52df1ee8ddf7c651034p-104L, +/* sin(x) = 0.4ccc7a50127e1de0cb6b40c302 c651f7bded4f9e7702b0471ae0 288d091a37391950907202f */ + 0x0.4ccc7a50127e1de0cb6b40c302p0L, + 0x0.c651f7bded4f9e7702b0471ae0p-104L, + +/* x = 3.12500000000000000000000000000000000e-01 3ffd4000000000000000000000000000 */ +/* cos(x) = 0.f399f500c9e9fd37ae9957263d ab8877102beb569f101ee44953 50868e5847d181d50d3cca2 */ + 0x0.f399f500c9e9fd37ae9957263dp0L, + 0x0.ab8877102beb569f101ee44953p-104L, +/* sin(x) = 0.4eb44a5da74f600207aaa090f0 734e288603ffadb3eb2542a469 77b105f8547128036dcf7f0 */ + 0x0.4eb44a5da74f600207aaa090f0p0L, + 0x0.734e288603ffadb3eb2542a469p-104L, + +/* x = 3.20312500000000000000000000000000000e-01 3ffd4800000000000000000000000000 */ +/* cos(x) = 0.f2faa5a1b74e82fd61fa05f917 7380e8e69b7b15a945e8e5ae11 24bf3d12b0617e03af4fab5 */ + 0x0.f2faa5a1b74e82fd61fa05f917p0L, + 0x0.7380e8e69b7b15a945e8e5ae11p-104L, +/* sin(x) = 0.509adf9a7b9a5a0f638a8fa3a6 0a199418859f18b37169a644fd b986c21ecb00133853bc35b */ + 0x0.509adf9a7b9a5a0f638a8fa3a6p0L, + 0x0.0a199418859f18b37169a644fdp-104L, + +/* x = 3.28125000000000000000000000000000000e-01 3ffd5000000000000000000000000000 */ +/* cos(x) = 0.f2578a595224dd2e6bfa2eb2f9 9cc674f5ea6f479eae2eb58018 6897ae3f893df1113ca06b8 */ + 0x0.f2578a595224dd2e6bfa2eb2f9p0L, + 0x0.9cc674f5ea6f479eae2eb58018p-104L, +/* sin(x) = 0.5280326c3cf481823ba6bb08ea c82c2093f2bce3c4eb4ee3dec7 df41c92c8a4226098616075 */ + 0x0.5280326c3cf481823ba6bb08eap0L, + 0x0.c82c2093f2bce3c4eb4ee3dec7p-104L, + +/* x = 3.35937500000000000000000000000000000e-01 3ffd5800000000000000000000000000 */ +/* cos(x) = 0.f1b0a5b406b526d886c55feadc 8d0dcc8eb9ae2ac707051771b4 8e05b25b000009660bdb3e3 */ + 0x0.f1b0a5b406b526d886c55feadcp0L, + 0x0.8d0dcc8eb9ae2ac707051771b4p-104L, +/* sin(x) = 0.54643b3da29de9b357155eef0f 332fb3e66c83bf4dddd9491c5e b8e103ccd92d6175220ed51 */ + 0x0.54643b3da29de9b357155eef0fp0L, + 0x0.332fb3e66c83bf4dddd9491c5ep-104L, + +/* x = 3.43750000000000000000000000000000000e-01 3ffd6000000000000000000000000000 */ +/* cos(x) = 0.f105fa4d66b607a67d44e04272 5204435142ac8ad54dfb0907a4 f6b56b06d98ee60f19e557a */ + 0x0.f105fa4d66b607a67d44e04272p0L, + 0x0.5204435142ac8ad54dfb0907a4p-104L, +/* sin(x) = 0.5646f27e8bd65cbe3a5d61ff06 572290ee826d9674a00246b05a e26753cdfc90d9ce81a7d02 */ + 0x0.5646f27e8bd65cbe3a5d61ff06p0L, + 0x0.572290ee826d9674a00246b05ap-104L, + +/* x = 3.51562500000000000000000000000000000e-01 3ffd6800000000000000000000000000 */ +/* cos(x) = 0.f0578ad01ede707fa39c09dc6b 984afef74f3dc8d0efb0f4c5a6 b13771145b3e0446fe33887 */ + 0x0.f0578ad01ede707fa39c09dc6bp0L, + 0x0.984afef74f3dc8d0efb0f4c5a6p-104L, +/* sin(x) = 0.582850a41e1dd46c7f602ea244 cdbbbfcdfa8f3189be794dda42 7ce090b5f85164f1f80ac13 */ + 0x0.582850a41e1dd46c7f602ea244p0L, + 0x0.cdbbbfcdfa8f3189be794dda42p-104L, + +/* x = 3.59375000000000000000000000000000000e-01 3ffd7000000000000000000000000000 */ +/* cos(x) = 0.efa559f5ec3aec3a4eb0331927 8a2d41fcf9189462261125fe61 47b078f1daa0b06750a1654 */ + 0x0.efa559f5ec3aec3a4eb0331927p0L, + 0x0.8a2d41fcf9189462261125fe61p-104L, +/* sin(x) = 0.5a084e28e35fda2776dfdbbb55 31d74ced2b5d17c0b1afc46475 29d50c295e36d8ceec126c1 */ + 0x0.5a084e28e35fda2776dfdbbb55p0L, + 0x0.31d74ced2b5d17c0b1afc46475p-104L, + +/* x = 3.67187500000000000000000000000000000e-01 3ffd7800000000000000000000000000 */ +/* cos(x) = 0.eeef6a879146af0bf9b95ea2ea 0ac0d3e2e4d7e15d93f48cbd41 bf8e4fded40bef69e19eafa */ + 0x0.eeef6a879146af0bf9b95ea2eap0L, + 0x0.0ac0d3e2e4d7e15d93f48cbd41p-104L, +/* sin(x) = 0.5be6e38ce8095542bc14ee9da0 d36483e6734bcab2e07624188a f5653f114eeb46738fa899d */ + 0x0.5be6e38ce8095542bc14ee9da0p0L, + 0x0.d36483e6734bcab2e07624188ap-104L, + +/* x = 3.75000000000000000000000000000000000e-01 3ffd8000000000000000000000000000 */ +/* cos(x) = 0.ee35bf5ccac89052cd91ddb734 d3a47e262e3b609db604e21705 3803be0091e76daf28a89b7 */ + 0x0.ee35bf5ccac89052cd91ddb734p0L, + 0x0.d3a47e262e3b609db604e21705p-104L, +/* sin(x) = 0.5dc40955d9084f48a94675a249 8de5d851320ff5528a6afb3f2e 24de240fce6cbed1ba0ccd6 */ + 0x0.5dc40955d9084f48a94675a249p0L, + 0x0.8de5d851320ff5528a6afb3f2ep-104L, + +/* x = 3.82812500000000000000000000000000000e-01 3ffd8800000000000000000000000000 */ +/* cos(x) = 0.ed785b5c44741b4493c56bcb9d 338a151c6f6b85d8f8aca658b2 8572c162b199680eb9304da */ + 0x0.ed785b5c44741b4493c56bcb9dp0L, + 0x0.338a151c6f6b85d8f8aca658b2p-104L, +/* sin(x) = 0.5f9fb80f21b53649c432540a50 e22c53057ff42ae0fdf1307760 dc0093f99c8efeb2fbd7073 */ + 0x0.5f9fb80f21b53649c432540a50p0L, + 0x0.e22c53057ff42ae0fdf1307760p-104L, + +/* x = 3.90625000000000000000000000000000000e-01 3ffd9000000000000000000000000000 */ +/* cos(x) = 0.ecb7417b8d4ee3fec37aba4073 aa48f1f14666006fb431d96713 03c8100d10190ec8179c41d */ + 0x0.ecb7417b8d4ee3fec37aba4073p0L, + 0x0.aa48f1f14666006fb431d96713p-104L, +/* sin(x) = 0.6179e84a09a5258a40e9b5face 03e525f8b5753cd0105d93fe62 98010c3458e84d75fe420e9 */ + 0x0.6179e84a09a5258a40e9b5facep0L, + 0x0.03e525f8b5753cd0105d93fe62p-104L, + +/* x = 3.98437500000000000000000000000000000e-01 3ffd9800000000000000000000000000 */ +/* cos(x) = 0.ebf274bf0bda4f62447e56a093 626798d3013b5942b1abfd155a acc9dc5c6d0806a20d6b9c1 */ + 0x0.ebf274bf0bda4f62447e56a093p0L, + 0x0.626798d3013b5942b1abfd155ap-104L, +/* sin(x) = 0.6352929dd264bd44a02ea76632 5d8aa8bd9695fc8def3caefba5 b94c9a3c873f7b2d3776ead */ + 0x0.6352929dd264bd44a02ea76632p0L, + 0x0.5d8aa8bd9695fc8def3caefba5p-104L, + +/* x = 4.06250000000000000000000000000000000e-01 3ffda000000000000000000000000000 */ +/* cos(x) = 0.eb29f839f201fd13b937968279 16a78f15c85230a4e8ea4b2155 8265a14367e1abb4c30695a */ + 0x0.eb29f839f201fd13b937968279p0L, + 0x0.16a78f15c85230a4e8ea4b2155p-104L, +/* sin(x) = 0.6529afa7d51b129631ec197c0a 840a11d7dc5368b0a47956feb2 85caa8371c4637ef17ef01b */ + 0x0.6529afa7d51b129631ec197c0ap0L, + 0x0.840a11d7dc5368b0a47956feb2p-104L, + +/* x = 4.14062500000000000000000000000000000e-01 3ffda800000000000000000000000000 */ +/* cos(x) = 0.ea5dcf0e30cf03e6976ef0b1ec 26515fba47383855c3b4055a99 b5e86824b2cd1a691fdca7b */ + 0x0.ea5dcf0e30cf03e6976ef0b1ecp0L, + 0x0.26515fba47383855c3b4055a99p-104L, +/* sin(x) = 0.66ff380ba0144109e39a320b0a 3fa5fd65ea0585bcbf9b1a769a 9b0334576c658139e1a1cbe */ + 0x0.66ff380ba0144109e39a320b0ap0L, + 0x0.3fa5fd65ea0585bcbf9b1a769ap-104L, + +/* x = 4.21875000000000000000000000000000000e-01 3ffdb000000000000000000000000000 */ +/* cos(x) = 0.e98dfc6c6be031e60dd3089cbd d18a75b1f6b2c1e97f79225202 f03dbea45b07a5ec4efc062 */ + 0x0.e98dfc6c6be031e60dd3089cbdp0L, + 0x0.d18a75b1f6b2c1e97f79225202p-104L, +/* sin(x) = 0.68d32473143327973bc712bcc4 ccddc47630d755850c0655243b 205934dc49ffed8eb76adcb */ + 0x0.68d32473143327973bc712bcc4p0L, + 0x0.ccddc47630d755850c0655243bp-104L, + +/* x = 4.29687500000000000000000000000000000e-01 3ffdb800000000000000000000000000 */ +/* cos(x) = 0.e8ba8393eca7821aa563d83491 b6101189b3b101c3677f73d7ba d7c10f9ee02b7ab4009739a */ + 0x0.e8ba8393eca7821aa563d83491p0L, + 0x0.b6101189b3b101c3677f73d7bap-104L, +/* sin(x) = 0.6aa56d8e8249db4eb60a761fe3 f9e559be456b9e13349ca99b0b fb787f22b95db3b70179615 */ + 0x0.6aa56d8e8249db4eb60a761fe3p0L, + 0x0.f9e559be456b9e13349ca99b0bp-104L, + +/* x = 4.37500000000000000000000000000000000e-01 3ffdc000000000000000000000000000 */ +/* cos(x) = 0.e7e367d2956cfb16b6aa11e541 9cd0057f5c132a6455bf064297 e6a76fe2b72bb630d6d50ff */ + 0x0.e7e367d2956cfb16b6aa11e541p0L, + 0x0.9cd0057f5c132a6455bf064297p-104L, +/* sin(x) = 0.6c760c14c8585a51dbd34660ae 6c52ac7036a0b40887a0b63724 f8b4414348c3063a637f457 */ + 0x0.6c760c14c8585a51dbd34660aep0L, + 0x0.6c52ac7036a0b40887a0b63724p-104L, + +/* x = 4.45312500000000000000000000000000000e-01 3ffdc800000000000000000000000000 */ +/* cos(x) = 0.e708ac84d4172a3e2737662213 429e14021074d7e702e77d72a8 f1101a7e70410df8273e9aa */ + 0x0.e708ac84d4172a3e2737662213p0L, + 0x0.429e14021074d7e702e77d72a8p-104L, +/* sin(x) = 0.6e44f8c36eb10a1c752d093c00 f4d47ba446ac4c215d26b03164 42f168459e677d06e7249e3 */ + 0x0.6e44f8c36eb10a1c752d093c00p0L, + 0x0.f4d47ba446ac4c215d26b03164p-104L, + +/* x = 4.53125000000000000000000000000000000e-01 3ffdd000000000000000000000000000 */ +/* cos(x) = 0.e62a551594b970a770b15d41d4 c0e483e47aca550111df6966f9 e7ac3a94ae49e6a71eb031e */ + 0x0.e62a551594b970a770b15d41d4p0L, + 0x0.c0e483e47aca550111df6966f9p-104L, +/* sin(x) = 0.70122c5ec5028c8cff33abf4fd 340ccc382e038379b09cf04f9a 52692b10b72586060cbb001 */ + 0x0.70122c5ec5028c8cff33abf4fdp0L, + 0x0.340ccc382e038379b09cf04f9ap-104L, + +/* x = 4.60937500000000000000000000000000000e-01 3ffdd800000000000000000000000000 */ +/* cos(x) = 0.e54864fe33e8575cabf5bd0e5c f1b1a8bc7c0d5f61702450fa6b 6539735820dd2603ae355d5 */ + 0x0.e54864fe33e8575cabf5bd0e5cp0L, + 0x0.f1b1a8bc7c0d5f61702450fa6bp-104L, +/* sin(x) = 0.71dd9fb1ff4677853acb970a9f 6729c6e3aac247b1c57cea66c7 7413f1f98e8b9e98e49d851 */ + 0x0.71dd9fb1ff4677853acb970a9fp0L, + 0x0.6729c6e3aac247b1c57cea66c7p-104L, + +/* x = 4.68750000000000000000000000000000000e-01 3ffde000000000000000000000000000 */ +/* cos(x) = 0.e462dfc670d421ab3d1a159012 28f146a0547011202bf5ab01f9 14431859aef577966bc4fa4 */ + 0x0.e462dfc670d421ab3d1a159012p0L, + 0x0.28f146a0547011202bf5ab01f9p-104L, +/* sin(x) = 0.73a74b8f52947b681baf6928eb 3fb021769bf4779bad0e3aa9b1 cdb75ec60aad9fc63ff19d5 */ + 0x0.73a74b8f52947b681baf6928ebp0L, + 0x0.3fb021769bf4779bad0e3aa9b1p-104L, + +/* x = 4.76562500000000000000000000000000000e-01 3ffde800000000000000000000000000 */ +/* cos(x) = 0.e379c9045f29d517c4808aa497 c2057b2b3d109e76c0dc302d4d 0698b36e3f0bdbf33d8e952 */ + 0x0.e379c9045f29d517c4808aa497p0L, + 0x0.c2057b2b3d109e76c0dc302d4dp-104L, +/* sin(x) = 0.756f28d011d98528a44a75fc29 c779bd734ecdfb582fdb74b68a 4c4c4be54cfd0b2d3ad292f */ + 0x0.756f28d011d98528a44a75fc29p0L, + 0x0.c779bd734ecdfb582fdb74b68ap-104L, + +/* x = 4.84375000000000000000000000000000000e-01 3ffdf000000000000000000000000000 */ +/* cos(x) = 0.e28d245c58baef72225e232abc 003c4366acd9eb4fc2808c2ab7 fe7676cf512ac7f945ae5fb */ + 0x0.e28d245c58baef72225e232abcp0L, + 0x0.003c4366acd9eb4fc2808c2ab7p-104L, +/* sin(x) = 0.77353054ca72690d4c6e171fd9 9e6b39fa8e1ede5f052fd29645 34c75340970a3a9cd3c5c32 */ + 0x0.77353054ca72690d4c6e171fd9p0L, + 0x0.9e6b39fa8e1ede5f052fd29645p-104L, + +/* x = 4.92187500000000000000000000000000000e-01 3ffdf800000000000000000000000000 */ +/* cos(x) = 0.e19cf580eeec046aa1422fa748 07ecefb2a1911c94e7b5f20a00 f70022d940193691e5bd790 */ + 0x0.e19cf580eeec046aa1422fa748p0L, + 0x0.07ecefb2a1911c94e7b5f20a00p-104L, +/* sin(x) = 0.78f95b0560a9a3bd6df7bd981d c38c61224d08bc20631ea932e6 05e53b579e9e0767dfcbbcb */ + 0x0.78f95b0560a9a3bd6df7bd981dp0L, + 0x0.c38c61224d08bc20631ea932e6p-104L, + +/* x = 5.00000000000000000000000000000000000e-01 3ffe0000000000000000000000000000 */ +/* cos(x) = 0.e0a94032dbea7cedbddd9da2fa fad98556566b3a89f43eabd723 50af3e8b19e801204d8fe2e */ + 0x0.e0a94032dbea7cedbddd9da2fap0L, + 0x0.fad98556566b3a89f43eabd723p-104L, +/* sin(x) = 0.7abba1d12c17bfa1d92f0d93f6 0ded9992f45b4fcaf13cd58b30 3693d2a0db47db35ae8a3a9 */ + 0x0.7abba1d12c17bfa1d92f0d93f6p0L, + 0x0.0ded9992f45b4fcaf13cd58b30p-104L, + +/* x = 5.07812500000000000000000000000000000e-01 3ffe0400000000000000000000000000 */ +/* cos(x) = 0.dfb20840f3a9b36f7ae2c51534 2890b5ec583b8366cc2b55029e 95094d31112383f2553498b */ + 0x0.dfb20840f3a9b36f7ae2c51534p0L, + 0x0.2890b5ec583b8366cc2b55029ep-104L, +/* sin(x) = 0.7c7bfdaf13e5ed17212f8a7525 bfb113aba6c0741b5362bb8d59 282a850b63716bca0c910f0 */ + 0x0.7c7bfdaf13e5ed17212f8a7525p0L, + 0x0.bfb113aba6c0741b5362bb8d59p-104L, + +/* x = 5.15625000000000000000000000000000000e-01 3ffe0800000000000000000000000000 */ +/* cos(x) = 0.deb7518814a7a931bbcc88c109 cd41c50bf8bb48f20ae8c36628 d1d3d57574f7dc58f27d91c */ + 0x0.deb7518814a7a931bbcc88c109p0L, + 0x0.cd41c50bf8bb48f20ae8c36628p-104L, +/* sin(x) = 0.7e3a679daaf25c676542bcb402 8d0964172961c921823a4ef0c3 a9070d886dbd073f6283699 */ + 0x0.7e3a679daaf25c676542bcb402p0L, + 0x0.8d0964172961c921823a4ef0c3p-104L, + +/* x = 5.23437500000000000000000000000000000e-01 3ffe0c00000000000000000000000000 */ +/* cos(x) = 0.ddb91ff318799172bd2452d0a3 889f5169c64a0094bcf0b8aa7d cf0d7640a2eba68955a80be */ + 0x0.ddb91ff318799172bd2452d0a3p0L, + 0x0.889f5169c64a0094bcf0b8aa7dp-104L, +/* sin(x) = 0.7ff6d8a34bd5e8fa54c97482db 5159df1f24e8038419c0b448b9 eea8939b5d4dfcf40900257 */ + 0x0.7ff6d8a34bd5e8fa54c97482dbp0L, + 0x0.5159df1f24e8038419c0b448b9p-104L, + +/* x = 5.31250000000000000000000000000000000e-01 3ffe1000000000000000000000000000 */ +/* cos(x) = 0.dcb7777ac420705168f31e3eb7 80ce9c939ecada62843b54522f 5407eb7f21e556059fcd734 */ + 0x0.dcb7777ac420705168f31e3eb7p0L, + 0x0.80ce9c939ecada62843b54522fp-104L, +/* sin(x) = 0.81b149ce34caa5a4e650f8d09f d4d6aa74206c32ca951a93074c 83b2d294d25dbb0f7fdfad2 */ + 0x0.81b149ce34caa5a4e650f8d09fp0L, + 0x0.d4d6aa74206c32ca951a93074cp-104L, + +/* x = 5.39062500000000000000000000000000000e-01 3ffe1400000000000000000000000000 */ +/* cos(x) = 0.dbb25c25b8260c14f6e7bc98ec 991b70c65335198b0ab628bad2 0cc7b229d4dd62183cfa055 */ + 0x0.dbb25c25b8260c14f6e7bc98ecp0L, + 0x0.991b70c65335198b0ab628bad2p-104L, +/* sin(x) = 0.8369b434a372da7eb5c8a71fe3 6ce1e0b2b493f6f5cb2e38bcae c2a556b3678c401940d1c3c */ + 0x0.8369b434a372da7eb5c8a71fe3p0L, + 0x0.6ce1e0b2b493f6f5cb2e38bcaep-104L, + +/* x = 5.46875000000000000000000000000000000e-01 3ffe1800000000000000000000000000 */ +/* cos(x) = 0.daa9d20860827063fde51c09e8 55e9932e1b17143e7244fd267a 899d41ae1f3bc6a0ec42e27 */ + 0x0.daa9d20860827063fde51c09e8p0L, + 0x0.55e9932e1b17143e7244fd267ap-104L, +/* sin(x) = 0.852010f4f0800521378bd8dd61 4753d080c2e9e0775ffc609947 b9132f5357404f464f06a58 */ + 0x0.852010f4f0800521378bd8dd61p0L, + 0x0.4753d080c2e9e0775ffc609947p-104L, + +/* x = 5.54687500000000000000000000000000000e-01 3ffe1c00000000000000000000000000 */ +/* cos(x) = 0.d99ddd44e44a43d4d4a3a3ed95 204106fd54d78e8c7684545c0d a0b7c2c72be7a89b7c182ad */ + 0x0.d99ddd44e44a43d4d4a3a3ed95p0L, + 0x0.204106fd54d78e8c7684545c0dp-104L, +/* sin(x) = 0.86d45935ab396cb4e421e822de e54f3562dfcefeaa782184c234 01d231f5ad981a1cc195b18 */ + 0x0.86d45935ab396cb4e421e822dep0L, + 0x0.e54f3562dfcefeaa782184c234p-104L, + +/* x = 5.62500000000000000000000000000000000e-01 3ffe2000000000000000000000000000 */ +/* cos(x) = 0.d88e820b1526311dd561efbc0c 1a9a5375eb26f65d246c5744b1 3ca26a7e0fd42556da843c8 */ + 0x0.d88e820b1526311dd561efbc0cp0L, + 0x0.1a9a5375eb26f65d246c5744b1p-104L, +/* sin(x) = 0.88868625b4e1dbb23133101330 22527200c143a5cb16637cb7da f8ade82459ff2e98511f40f */ + 0x0.88868625b4e1dbb23133101330p0L, + 0x0.22527200c143a5cb16637cb7dap-104L, + +/* x = 5.70312500000000000000000000000000000e-01 3ffe2400000000000000000000000000 */ +/* cos(x) = 0.d77bc4985e93a607c9d868b906 bbc6bbe3a04258814acb035846 8b826fc91bd4d814827f65e */ + 0x0.d77bc4985e93a607c9d868b906p0L, + 0x0.bbc6bbe3a04258814acb035846p-104L, +/* sin(x) = 0.8a3690fc5bfc11bf9535e2739a 8512f448a41251514bbed7fc18 d530f9b4650fcbb2861b0aa */ + 0x0.8a3690fc5bfc11bf9535e2739ap0L, + 0x0.8512f448a41251514bbed7fc18p-104L, + +/* x = 5.78125000000000000000000000000000000e-01 3ffe2800000000000000000000000000 */ +/* cos(x) = 0.d665a937b4ef2b1f6d51bad6d9 88a4419c1d7051faf31a9efa15 1d7631117efac03713f950a */ + 0x0.d665a937b4ef2b1f6d51bad6d9p0L, + 0x0.88a4419c1d7051faf31a9efa15p-104L, +/* sin(x) = 0.8be472f9776d809af2b8817124 3d63d66dfceeeb739cc894e023 fbc165a0e3f26ff729c5d57 */ + 0x0.8be472f9776d809af2b8817124p0L, + 0x0.3d63d66dfceeeb739cc894e023p-104L, + +/* x = 5.85937500000000000000000000000000000e-01 3ffe2c00000000000000000000000000 */ +/* cos(x) = 0.d54c3441844897fc8f853f0655 f1ba695eba9fbfd7439dbb1171 d862d9d9146ca5136f825ac */ + 0x0.d54c3441844897fc8f853f0655p0L, + 0x0.f1ba695eba9fbfd7439dbb1171p-104L, +/* sin(x) = 0.8d902565817ee7839bce3cd128 060119492cd36d42d82ada30d7 f8bde91324808377ddbf5d4 */ + 0x0.8d902565817ee7839bce3cd128p0L, + 0x0.060119492cd36d42d82ada30d7p-104L, + +/* x = 5.93750000000000000000000000000000000e-01 3ffe3000000000000000000000000000 */ +/* cos(x) = 0.d42f6a1b9f0168cdf031c2f63c 8d9304d86f8d34cb1d5fccb68c a0f2241427fc18d1fd5bbdf */ + 0x0.d42f6a1b9f0168cdf031c2f63cp0L, + 0x0.8d9304d86f8d34cb1d5fccb68cp-104L, +/* sin(x) = 0.8f39a191b2ba6122a3fa4f41d5 a3ffd421417d46f19a22230a14 f7fcc8fce5c75b4b28b29d1 */ + 0x0.8f39a191b2ba6122a3fa4f41d5p0L, + 0x0.a3ffd421417d46f19a22230a14p-104L, + +/* x = 6.01562500000000000000000000000000000e-01 3ffe3400000000000000000000000000 */ +/* cos(x) = 0.d30f4f392c357ab0661c5fa8a7 d9b26627846fef214b1d19a223 79ff9eddba087cf410eb097 */ + 0x0.d30f4f392c357ab0661c5fa8a7p0L, + 0x0.d9b26627846fef214b1d19a223p-104L, +/* sin(x) = 0.90e0e0d81ca678796cc92c8ea8 c2815bc72ca78abe571bfa8576 aacc571e096a33237e0e830 */ + 0x0.90e0e0d81ca678796cc92c8ea8p0L, + 0x0.c2815bc72ca78abe571bfa8576p-104L, + +/* x = 6.09375000000000000000000000000000000e-01 3ffe3800000000000000000000000000 */ +/* cos(x) = 0.d1ebe81a95ee752e48a26bcd32 d6e922d7eb44b8ad2232f69307 95e84b56317269b9dd1dfa6 */ + 0x0.d1ebe81a95ee752e48a26bcd32p0L, + 0x0.d6e922d7eb44b8ad2232f69307p-104L, +/* sin(x) = 0.9285dc9bc45dd9ea3d02457bcc e59c4175aab6ff7929a8d28719 5525fdace200dba032874fb */ + 0x0.9285dc9bc45dd9ea3d02457bccp0L, + 0x0.e59c4175aab6ff7929a8d28719p-104L, + +/* x = 6.17187500000000000000000000000000000e-01 3ffe3c00000000000000000000000000 */ +/* cos(x) = 0.d0c5394d772228195e25736c03 574707de0af1ca344b13bd3914 bfe27518e9e426f5deff1e1 */ + 0x0.d0c5394d772228195e25736c03p0L, + 0x0.574707de0af1ca344b13bd3914p-104L, +/* sin(x) = 0.94288e48bd0335fc41c4cbd292 0497a8f5d1d8185c99fa0081f9 0c27e2a53ffdd208a0dbe69 */ + 0x0.94288e48bd0335fc41c4cbd292p0L, + 0x0.0497a8f5d1d8185c99fa0081f9p-104L, + +/* x = 6.25000000000000000000000000000000000e-01 3ffe4000000000000000000000000000 */ +/* cos(x) = 0.cf9b476c897c25c5bfe750dd3f 308eaf7bcc1ed00179a256870f 4200445043dcdb1974b5878 */ + 0x0.cf9b476c897c25c5bfe750dd3fp0L, + 0x0.308eaf7bcc1ed00179a256870fp-104L, +/* sin(x) = 0.95c8ef544210ec0b91c49bd2aa 09e8515fa61a156ebb10f5f8c2 32a6445b61ebf3c2ec268f9 */ + 0x0.95c8ef544210ec0b91c49bd2aap0L, + 0x0.09e8515fa61a156ebb10f5f8c2p-104L, + +/* x = 6.32812500000000000000000000000000000e-01 3ffe4400000000000000000000000000 */ +/* cos(x) = 0.ce6e171f92f2e27f32225327ec 440ddaefae248413efc0e58cee e1ae369aabe73f88c87ed1a */ + 0x0.ce6e171f92f2e27f32225327ecp0L, + 0x0.440ddaefae248413efc0e58ceep-104L, +/* sin(x) = 0.9766f93cd18413a6aafc1cfc6f c28abb6817bf94ce349901ae3f 48c3215d3eb60acc5f78903 */ + 0x0.9766f93cd18413a6aafc1cfc6fp0L, + 0x0.c28abb6817bf94ce349901ae3fp-104L, + +/* x = 6.40625000000000000000000000000000000e-01 3ffe4800000000000000000000000000 */ +/* cos(x) = 0.cd3dad1b5328a2e459f993f4f5 108819faccbc4eeba9604e81c7 adad51cc8a2561631a06826 */ + 0x0.cd3dad1b5328a2e459f993f4f5p0L, + 0x0.108819faccbc4eeba9604e81c7p-104L, +/* sin(x) = 0.9902a58a45e27bed68412b426b 675ed503f54d14c8172e0d373f 42cadf04daf67319a7f94be */ + 0x0.9902a58a45e27bed68412b426bp0L, + 0x0.675ed503f54d14c8172e0d373fp-104L, + +/* x = 6.48437500000000000000000000000000000e-01 3ffe4c00000000000000000000000000 */ +/* cos(x) = 0.cc0a0e21709883a3ff00911e11 a07ee3bd7ea2b04e081be99be0 264791170761ae64b8b744a */ + 0x0.cc0a0e21709883a3ff00911e11p0L, + 0x0.a07ee3bd7ea2b04e081be99be0p-104L, +/* sin(x) = 0.9a9bedcdf01b38d993f3d78207 81de292033ead73b89e28f3931 3dbe3a6e463f845b5fa8490 */ + 0x0.9a9bedcdf01b38d993f3d78207p0L, + 0x0.81de292033ead73b89e28f3931p-104L, + +/* x = 6.56250000000000000000000000000000000e-01 3ffe5000000000000000000000000000 */ +/* cos(x) = 0.cad33f00658fe5e8204bbc0f3a 66a0e6a773f87987a780b243d7 be83b3db1448ca0e0e62787 */ + 0x0.cad33f00658fe5e8204bbc0f3ap0L, + 0x0.66a0e6a773f87987a780b243d7p-104L, +/* sin(x) = 0.9c32cba2b14156ef05256c4f85 7991ca6a547cd7ceb1ac8a8e62 a282bd7b9183648a462bd04 */ + 0x0.9c32cba2b14156ef05256c4f85p0L, + 0x0.7991ca6a547cd7ceb1ac8a8e62p-104L, + +/* x = 6.64062500000000000000000000000000000e-01 3ffe5400000000000000000000000000 */ +/* cos(x) = 0.c99944936cf48c8911ff93fe64 b3ddb7981e414bdaf6aae12035 77de44878c62bc3bc9cf7b9 */ + 0x0.c99944936cf48c8911ff93fe64p0L, + 0x0.b3ddb7981e414bdaf6aae12035p-104L, +/* sin(x) = 0.9dc738ad14204e689ac582d0f8 5826590feece34886cfefe2e08 cf2bb8488d55424dc9d3525 */ + 0x0.9dc738ad14204e689ac582d0f8p0L, + 0x0.5826590feece34886cfefe2e08p-104L, + +/* x = 6.71875000000000000000000000000000000e-01 3ffe5800000000000000000000000000 */ +/* cos(x) = 0.c85c23c26ed7b6f014ef546c47 929682122876bfbf157de0aff3 c4247d820c746e32cd4174f */ + 0x0.c85c23c26ed7b6f014ef546c47p0L, + 0x0.929682122876bfbf157de0aff3p-104L, +/* sin(x) = 0.9f592e9b66a9cf906a3c7aa3c1 0199849040c45ec3f0a7475973 11038101780c5f266059dbf */ + 0x0.9f592e9b66a9cf906a3c7aa3c1p0L, + 0x0.0199849040c45ec3f0a7475973p-104L, + +/* x = 6.79687500000000000000000000000000000e-01 3ffe5c00000000000000000000000000 */ +/* cos(x) = 0.c71be181ecd6875ce2da5615a0 3cca207d9adcb9dfb0a1d6c40a 4f0056437f1a59ccddd06ee */ + 0x0.c71be181ecd6875ce2da5615a0p0L, + 0x0.3cca207d9adcb9dfb0a1d6c40ap-104L, +/* sin(x) = 0.a0e8a725d33c828c11fa50fd9e 9a15ffecfad43f3e534358076b 9b0f6865694842b1e8c67dc */ + 0x0.a0e8a725d33c828c11fa50fd9ep0L, + 0x0.9a15ffecfad43f3e534358076bp-104L, + +/* x = 6.87500000000000000000000000000000000e-01 3ffe6000000000000000000000000000 */ +/* cos(x) = 0.c5d882d2ee48030c7c07d28e98 1e34804f82ed4cf93655d23653 89b716de6ad44676a1cc5da */ + 0x0.c5d882d2ee48030c7c07d28e98p0L, + 0x0.1e34804f82ed4cf93655d23653p-104L, +/* sin(x) = 0.a2759c0e79c35582527c32b55f 5405c182c66160cb1d9eb7bb0b 7cdf4ad66f317bda4332914 */ + 0x0.a2759c0e79c35582527c32b55fp0L, + 0x0.5405c182c66160cb1d9eb7bb0bp-104L, + +/* x = 6.95312500000000000000000000000000000e-01 3ffe6400000000000000000000000000 */ +/* cos(x) = 0.c4920cc2ec38fb891b38827db0 8884fc66371ac4c2052ca8885b 981bbcfd3bb7b093ee31515 */ + 0x0.c4920cc2ec38fb891b38827db0p0L, + 0x0.8884fc66371ac4c2052ca8885bp-104L, +/* sin(x) = 0.a400072188acf49cd6b173825e 038346f105e1301afe642bcc36 4cea455e21e506e3e927ed8 */ + 0x0.a400072188acf49cd6b173825ep0L, + 0x0.038346f105e1301afe642bcc36p-104L, + +/* x = 7.03125000000000000000000000000000000e-01 3ffe6800000000000000000000000000 */ +/* cos(x) = 0.c348846bbd3631338ffe2bfe9d d1381a35b4e9c0c51b4c13fe37 6bad1bf5caacc4542be0aa9 */ + 0x0.c348846bbd3631338ffe2bfe9dp0L, + 0x0.d1381a35b4e9c0c51b4c13fe37p-104L, +/* sin(x) = 0.a587e23555bb08086d02b9c662 cdd29316c3e9bd08d93793634a 21b1810cce73bdb97a99b9e */ + 0x0.a587e23555bb08086d02b9c662p0L, + 0x0.cdd29316c3e9bd08d93793634ap-104L, + +/* x = 7.10937500000000000000000000000000000e-01 3ffe6c00000000000000000000000000 */ +/* cos(x) = 0.c1fbeef380e4ffdd5a613ec872 2f643ffe814ec2343e53adb549 627224fdc9f2a7b77d3d69f */ + 0x0.c1fbeef380e4ffdd5a613ec872p0L, + 0x0.2f643ffe814ec2343e53adb549p-104L, +/* sin(x) = 0.a70d272a76a8d4b6da0ec90712 bb748b96dabf88c3079246f3db 7eea6e58ead4ed0e2843303 */ + 0x0.a70d272a76a8d4b6da0ec90712p0L, + 0x0.bb748b96dabf88c3079246f3dbp-104L, + +/* x = 7.18750000000000000000000000000000000e-01 3ffe7000000000000000000000000000 */ +/* cos(x) = 0.c0ac518c8b6ae710ba37a3eeb9 0cb15aebcb8bed4356fb507a48 a6e97de9aa6d9660116b436 */ + 0x0.c0ac518c8b6ae710ba37a3eeb9p0L, + 0x0.0cb15aebcb8bed4356fb507a48p-104L, +/* sin(x) = 0.a88fcfebd9a8dd47e2f3c76ef9 e2439920f7e7fbe735f8bcc985 491ec6f12a2d4214f8cfa99 */ + 0x0.a88fcfebd9a8dd47e2f3c76ef9p0L, + 0x0.e2439920f7e7fbe735f8bcc985p-104L, + +/* x = 7.26562500000000000000000000000000000e-01 3ffe7400000000000000000000000000 */ +/* cos(x) = 0.bf59b17550a440687596929656 7cf3e3b4e483061877c02811c6 cae85fad5a6c3da58f49292 */ + 0x0.bf59b17550a440687596929656p0L, + 0x0.7cf3e3b4e483061877c02811c6p-104L, +/* sin(x) = 0.aa0fd66eddb921232c28520d39 11b8a03193b47f187f1471ac21 6fbcd5bb81029294d3a73f1 */ + 0x0.aa0fd66eddb921232c28520d39p0L, + 0x0.11b8a03193b47f187f1471ac21p-104L, + +/* x = 7.34375000000000000000000000000000000e-01 3ffe7800000000000000000000000000 */ +/* cos(x) = 0.be0413f84f2a771c614946a88c bf4da1d75a5560243de8f2283f efa0ea4a48468a52d51d8b3 */ + 0x0.be0413f84f2a771c614946a88cp0L, + 0x0.bf4da1d75a5560243de8f2283fp-104L, +/* sin(x) = 0.ab8d34b36acd987210ed343ec6 5d7e3adc2e7109fce43d55c8d5 7dfdf55b9e01d2cc1f1b9ec */ + 0x0.ab8d34b36acd987210ed343ec6p0L, + 0x0.5d7e3adc2e7109fce43d55c8d5p-104L, + +/* x = 7.42187500000000000000000000000000000e-01 3ffe7c00000000000000000000000000 */ +/* cos(x) = 0.bcab7e6bfb2a14a9b122c574a3 76bec98ab14808c64a4e731b34 047e217611013ac99c0f25d */ + 0x0.bcab7e6bfb2a14a9b122c574a3p0L, + 0x0.76bec98ab14808c64a4e731b34p-104L, +/* sin(x) = 0.ad07e4c409d08c4fa3a9057bb0 ac24b8636e74e76f51e09bd6b2 319707cbd9f5e254643897a */ + 0x0.ad07e4c409d08c4fa3a9057bb0p0L, + 0x0.ac24b8636e74e76f51e09bd6b2p-104L, + +/* x = 7.50000000000000000000000000000000000e-01 3ffe8000000000000000000000000000 */ +/* cos(x) = 0.bb4ff632a908f73ec151839cb9 d993b4e0bfb8f20e7e44e6e4ae e845e35575c3106dbe6fd06 */ + 0x0.bb4ff632a908f73ec151839cb9p0L, + 0x0.d993b4e0bfb8f20e7e44e6e4aep-104L, +/* sin(x) = 0.ae7fe0b5fc786b2d966e1d6af1 40a488476747c2646425fc7533 f532cd044cb10a971a49a6a */ + 0x0.ae7fe0b5fc786b2d966e1d6af1p0L, + 0x0.40a488476747c2646425fc7533p-104L, + +/* x = 7.57812500000000000000000000000000000e-01 3ffe8400000000000000000000000000 */ +/* cos(x) = 0.b9f180ba77dd0751628e135a95 08299012230f14becacdd14c3f 8862d122de5b56d55b53360 */ + 0x0.b9f180ba77dd0751628e135a95p0L, + 0x0.08299012230f14becacdd14c3fp-104L, +/* sin(x) = 0.aff522a954f2ba16d9defdc416 e33f5e9a5dfd5a6c228e0abc4d 521327ff6e2517a7b3851dd */ + 0x0.aff522a954f2ba16d9defdc416p0L, + 0x0.e33f5e9a5dfd5a6c228e0abc4dp-104L, + +/* x = 7.65625000000000000000000000000000000e-01 3ffe8800000000000000000000000000 */ +/* cos(x) = 0.b890237d3bb3c284b614a05390 16bfa1053730bbdf940fa895e1 85f8e58884d3dda15e63371 */ + 0x0.b890237d3bb3c284b614a05390p0L, + 0x0.16bfa1053730bbdf940fa895e1p-104L, +/* sin(x) = 0.b167a4c90d63c4244cf5493b7c c23bd3c3c1225e078baa0c53d6 d400b926281f537a1a260e6 */ + 0x0.b167a4c90d63c4244cf5493b7cp0L, + 0x0.c23bd3c3c1225e078baa0c53d6p-104L, + +/* x = 7.73437500000000000000000000000000000e-01 3ffe8c00000000000000000000000000 */ +/* cos(x) = 0.b72be40067aaf2c050dbdb7a14 c3d7d4f203f6b3f0224a4afe55 d6ec8e92b508fd5c5984b3b */ + 0x0.b72be40067aaf2c050dbdb7a14p0L, + 0x0.c3d7d4f203f6b3f0224a4afe55p-104L, +/* sin(x) = 0.b2d7614b1f3aaa24df2d6e20a7 7e1ca3e6d838c03e29c1bcb026 e6733324815fadc9eb89674 */ + 0x0.b2d7614b1f3aaa24df2d6e20a7p0L, + 0x0.7e1ca3e6d838c03e29c1bcb026p-104L, + +/* x = 7.81250000000000000000000000000000000e-01 3ffe9000000000000000000000000000 */ +/* cos(x) = 0.b5c4c7d4f7dae915ac786ccf4b 1a498d3e73b6e5e74fe7519d9c 53ee6d6b90e881bddfc33e1 */ + 0x0.b5c4c7d4f7dae915ac786ccf4bp0L, + 0x0.1a498d3e73b6e5e74fe7519d9cp-104L, +/* sin(x) = 0.b44452709a5975290591376543 4a59d111f0433eb2b133f7d103 207e2aeb4aae111ddc385b3 */ + 0x0.b44452709a5975290591376543p0L, + 0x0.4a59d111f0433eb2b133f7d103p-104L, + +/* x = 7.89062500000000000000000000000000000e-01 3ffe9400000000000000000000000000 */ +/* cos(x) = 0.b45ad4975b1294cadca4cf40ec 8f22a68cd14b175835239a37e6 3acb85e8e9505215df18140 */ + 0x0.b45ad4975b1294cadca4cf40ecp0L, + 0x0.8f22a68cd14b175835239a37e6p-104L, +/* sin(x) = 0.b5ae7285bc10cf515753847e8f 8b7a30e0a580d929d770103509 880680f7b8b0e8ad23b65d8 */ + 0x0.b5ae7285bc10cf515753847e8fp0L, + 0x0.8b7a30e0a580d929d770103509p-104L +}; diff --git a/sysdeps/ieee754/ldbl-128ibm/w_expl.c b/sysdeps/ieee754/ldbl-128ibm/w_expl.c new file mode 100644 index 0000000..a5e72b2 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm/w_expl.c @@ -0,0 +1,6 @@ +/* Looks like we can use ieee854 w_expl.c as is for IBM extended format. */ +#include +#undef weak_alias +#define weak_alias(n,a) +#include +long_double_symbol (libm, __expl, expl); diff --git a/sysdeps/powerpc/Implies b/sysdeps/powerpc/Implies index 12ca48b..7ccf9a7 100644 --- a/sysdeps/powerpc/Implies +++ b/sysdeps/powerpc/Implies @@ -1,2 +1,4 @@ -ieee754/flt-32 +# On PowerPC we use the IBM extended long double format. +ieee754/ldbl-128ibm ieee754/dbl-64 +ieee754/flt-32 diff --git a/sysdeps/powerpc/fpu/bits/mathdef.h b/sysdeps/powerpc/fpu/bits/mathdef.h index 3a9d538..b79cc6f 100644 --- a/sysdeps/powerpc/fpu/bits/mathdef.h +++ b/sysdeps/powerpc/fpu/bits/mathdef.h @@ -1,4 +1,5 @@ -/* Copyright (C) 1997,1998,1999,2000,2003,2004 Free Software Foundation, Inc. +/* Copyright (C) 1997,1998,1999,2000,2003,2004,2006 + Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -61,9 +62,3 @@ typedef double double_t; # define FP_ILOGBNAN (2147483647) #endif /* ISO C99 */ - -#ifndef __NO_LONG_DOUBLE_MATH -/* Signal that we do not really have a `long double'. The disables the - declaration of all the `long double' function variants. */ -# define __NO_LONG_DOUBLE_MATH 1 -#endif diff --git a/sysdeps/powerpc/fpu/libm-test-ulps b/sysdeps/powerpc/fpu/libm-test-ulps index 4e1160a..46c7666 100644 --- a/sysdeps/powerpc/fpu/libm-test-ulps +++ b/sysdeps/powerpc/fpu/libm-test-ulps @@ -1,6 +1,19 @@ # Begin of automatic generation +# acos +Test "acos (2e-17) == 1.57079632679489659923132169163975144": +ildouble: 1 +ldouble: 1 + +# asin +Test "asin (0.75) == 0.848062078981481008052944338998418080": +ildouble: 2 +ldouble: 2 + # atan2 +Test "atan2 (-0.00756827042671106339, -.001792735857538728036) == -1.80338464113663849327153994379639112": +ildouble: 1 +ldouble: 1 Test "atan2 (-0.75, -1.0) == -2.49809154479650885165983415456218025": float: 1 ifloat: 1 @@ -10,25 +23,28 @@ ifloat: 1 Test "atan2 (1.390625, 0.9296875) == 0.981498387184244311516296577615519772": float: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 # atanh Test "atanh (0.75) == 0.972955074527656652552676371721589865": float: 1 ifloat: 1 +# cabs +Test "cabs (0.75 + 1.25 i) == 1.45773797371132511771853821938639577": +ildouble: 1 +ldouble: 1 + # cacosh -Test "Real part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i": -double: 1 -float: 7 -idouble: 1 -ifloat: 7 Test "Imaginary part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i": -double: 1 -float: 3 -idouble: 1 -ifloat: 3 +float: 1 +ifloat: 1 # casin +Test "Real part of: casin (-2 - 3 i) == -0.57065278432109940071028387968566963 - 1.9833870299165354323470769028940395 i": +ildouble: 1 +ldouble: 1 Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i": double: 1 float: 1 @@ -41,11 +57,15 @@ double: 5 float: 1 idouble: 5 ifloat: 1 +ildouble: 4 +ldouble: 4 Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i": double: 3 float: 6 idouble: 3 ifloat: 6 +ildouble: 1 +ldouble: 1 Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i": float: 1 ifloat: 1 @@ -57,30 +77,21 @@ ifloat: 1 # catan Test "Real part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i": -float: 3 -ifloat: 3 +ildouble: 1 +ldouble: 1 Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i": double: 1 float: 1 idouble: 1 ifloat: 1 -Test "Real part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i": -float: 4 -ifloat: 4 # catanh Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i": double: 4 idouble: 4 -Test "Imaginary part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i": -float: 4 -ifloat: 4 Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i": double: 1 idouble: 1 -Test "Imaginary part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i": -float: 6 -ifloat: 6 # cbrt Test "cbrt (-27.0) == -3.0": @@ -115,9 +126,13 @@ double: 1 float: 1 idouble: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i": float: 1 ifloat: 1 +ildouble: 2 +ldouble: 2 # cexp Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i": @@ -126,101 +141,175 @@ ifloat: 1 Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i": float: 1 ifloat: 1 +ildouble: 2 +ldouble: 2 +Test "Imaginary part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i": +ildouble: 1 +ldouble: 1 # clog Test "Imaginary part of: clog (-2 - 3 i) == 1.2824746787307683680267437207826593 - 2.1587989303424641704769327722648368 i": -float: 3 -ifloat: 3 +ildouble: 1 +ldouble: 1 Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i": float: 1 ifloat: 1 +ildouble: 2 +ldouble: 2 +Test "Imaginary part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i": +ildouble: 1 +ldouble: 1 # clog10 Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i": +double: 1 float: 1 +idouble: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i": +double: 1 float: 1 +idouble: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i": double: 1 -float: 5 idouble: 1 -ifloat: 5 +ildouble: 1 +ldouble: 1 Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i": +double: 1 float: 1 +idouble: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i": +double: 1 float: 1 +idouble: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i": +double: 1 float: 1 +idouble: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i": +double: 1 float: 1 +idouble: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "Imaginary part of: clog10 (-inf + inf i) == inf + 3/4 pi*log10(e) i": +double: 1 +idouble: 1 Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i": +double: 1 float: 1 +idouble: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i": +double: 1 float: 1 +idouble: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i": +double: 1 float: 1 +idouble: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i": +double: 1 float: 1 +idouble: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i": float: 1 ifloat: 1 +ildouble: 2 +ldouble: 2 Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i": +double: 1 float: 1 +idouble: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i": +double: 1 float: 1 +idouble: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i": +double: 1 float: 1 +idouble: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i": +double: 1 float: 1 +idouble: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 # cos Test "cos (M_PI_6l * 2.0) == 0.5": double: 1 -float: 1 idouble: 1 -ifloat: 1 Test "cos (M_PI_6l * 4.0) == -0.5": double: 2 float: 1 idouble: 2 ifloat: 1 -Test "cos (pi/2) == 0": -double: 1 -float: 1 -idouble: 1 -ifloat: 1 # cpow Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i": float: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i": float: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i": double: 1 float: 4 idouble: 1 ifloat: 4 +Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i": +ildouble: 2 +ldouble: 2 Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i": double: 2 float: 3 idouble: 2 ifloat: 3 +Test "Real part of: cpow (2 + 0 i, 10 + 0 i) == 1024.0 + 0.0 i": +ildouble: 1 +ldouble: 1 Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i": double: 1 float: 5 @@ -229,11 +318,15 @@ ifloat: 5 Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i": float: 2 ifloat: 2 +ildouble: 2 +ldouble: 2 Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i": double: 2 float: 2 idouble: 2 ifloat: 2 +ildouble: 2 +ldouble: 2 # csinh Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i": @@ -242,9 +335,13 @@ idouble: 1 Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i": float: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i": float: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 # csqrt Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i": @@ -255,9 +352,9 @@ float: 1 ifloat: 1 # ctan -Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i": -double: 1 -idouble: 1 +Test "Imaginary part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i": +ildouble: 1 +ldouble: 1 Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i": double: 1 idouble: 1 @@ -274,6 +371,8 @@ ifloat: 1 Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i": double: 1 idouble: 1 +ildouble: 1 +ldouble: 1 # erf Test "erf (1.25) == 0.922900128256458230136523481197281140": @@ -291,29 +390,50 @@ Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8": double: 1 idouble: 1 +# exp +Test "exp (0.75) == 2.11700001661267466854536981983709561": +ildouble: 1 +ldouble: 1 +Test "exp (50.0) == 5184705528587072464087.45332293348538": +ildouble: 1 +ldouble: 1 + # exp10 Test "exp10 (-1) == 0.1": double: 2 float: 1 idouble: 2 ifloat: 1 +ildouble: 1 +ldouble: 1 Test "exp10 (0.75) == 5.62341325190349080394951039776481231": double: 1 float: 1 idouble: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Test "exp10 (3) == 1000": double: 6 float: 2 idouble: 6 ifloat: 2 +ildouble: 8 +ldouble: 8 + +# exp2 +Test "exp2 (10) == 1024": +ildouble: 2 +ldouble: 2 # expm1 Test "expm1 (0.75) == 1.11700001661267466854536981983709561": double: 1 idouble: 1 Test "expm1 (1) == M_El - 1.0": +double: 1 float: 1 +idouble: 1 ifloat: 1 # hypot @@ -335,6 +455,9 @@ ifloat: 1 Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271": float: 1 ifloat: 1 +Test "hypot (0.75, 1.25) == 1.45773797371132511771853821938639577": +ildouble: 1 +ldouble: 1 Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271": float: 1 ifloat: 1 @@ -345,84 +468,121 @@ ifloat: 1 # j0 Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1": double: 1 -float: 2 +float: 1 idouble: 1 -ifloat: 2 -Test "j0 (2.0) == 0.223890779141235668051827454649948626": -float: 2 -ifloat: 2 +ifloat: 1 +ildouble: 43515227266289159395415763648 +ldouble: 43515227266289159395415763648 Test "j0 (10.0) == -0.245935764451348335197760862485328754": -double: 3 +double: 2 float: 1 -idouble: 3 +idouble: 2 ifloat: 1 +ildouble: 17369667313819348747894233118595 +ldouble: 17369667313819348747894233118595 +Test "j0 (2.0) == 0.223890779141235668051827454649948626": +float: 2 +ifloat: 2 Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1": double: 1 -float: 2 +float: 1 idouble: 1 -ifloat: 2 +ifloat: 1 +ildouble: 43515227266289159395415763648 +ldouble: 43515227266289159395415763648 Test "j0 (8.0) == 0.171650807137553906090869407851972001": float: 1 ifloat: 1 +ildouble: 38324122909174090074461780712157 +ldouble: 38324122909174090074461780712157 # j1 Test "j1 (10.0) == 0.0434727461688614366697487680258592883": float: 2 ifloat: 2 +ildouble: 21475644881377747614143400473061 +ldouble: 21475644881377747614143400473061 Test "j1 (2.0) == 0.576724807756873387202448242269137087": double: 1 idouble: 1 Test "j1 (8.0) == 0.234636346853914624381276651590454612": double: 1 idouble: 1 +ildouble: 1790984160474480772420978558547 +ldouble: 1790984160474480772420978558547 # jn Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1": double: 1 -float: 2 +float: 1 idouble: 1 -ifloat: 2 -Test "jn (0, 2.0) == 0.223890779141235668051827454649948626": -float: 2 -ifloat: 2 +ifloat: 1 +ildouble: 43515227266289159395415763648 +ldouble: 43515227266289159395415763648 Test "jn (0, 10.0) == -0.245935764451348335197760862485328754": -double: 3 +double: 2 float: 1 -idouble: 3 +idouble: 2 ifloat: 1 +ildouble: 17369667313819348747894233118595 +ldouble: 17369667313819348747894233118595 +Test "jn (0, 2.0) == 0.223890779141235668051827454649948626": +float: 2 +ifloat: 2 Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1": double: 1 -float: 2 +float: 1 idouble: 1 -ifloat: 2 +ifloat: 1 +ildouble: 43515227266289159395415763648 +ldouble: 43515227266289159395415763648 Test "jn (0, 8.0) == 0.171650807137553906090869407851972001": float: 1 ifloat: 1 +ildouble: 38324122909174090074461780712157 +ldouble: 38324122909174090074461780712157 Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883": float: 2 ifloat: 2 +ildouble: 21475644881377747614143400473061 +ldouble: 21475644881377747614143400473061 Test "jn (1, 2.0) == 0.576724807756873387202448242269137087": double: 1 idouble: 1 Test "jn (1, 8.0) == 0.234636346853914624381276651590454612": double: 1 idouble: 1 +ildouble: 1790984160474480772420978558547 +ldouble: 1790984160474480772420978558547 +Test "jn (10, -1.0) == 0.263061512368745320699785368779050294e-9": +ildouble: 1 +ldouble: 1 Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18": double: 1 float: 1 idouble: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10": double: 1 float: 1 idouble: 1 ifloat: 1 +Test "jn (10, 1.0) == 0.263061512368745320699785368779050294e-9": +ildouble: 1 +ldouble: 1 Test "jn (10, 10.0) == 0.207486106633358857697278723518753428": float: 1 ifloat: 1 +ildouble: 24853547691922812960150086146551 +ldouble: 24853547691922812960150086146551 Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6": float: 4 ifloat: 4 +Test "jn (3, -1.0) == -0.0195633539826684059189053216217515083": +ildouble: 1 +ldouble: 1 Test "jn (3, 0.125) == 0.406503832554912875023029337653442868e-4": double: 1 float: 1 @@ -431,16 +591,23 @@ ifloat: 1 Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2": double: 1 idouble: 1 +Test "jn (3, 1.0) == 0.0195633539826684059189053216217515083": +ildouble: 1 +ldouble: 1 Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563": double: 3 -float: 2 +float: 1 idouble: 3 -ifloat: 2 +ifloat: 1 +ildouble: 47549060992978485557887362065694 +ldouble: 47549060992978485557887362065694 Test "jn (3, 2.0) == 0.128943249474402051098793332969239835": double: 1 float: 2 idouble: 1 ifloat: 2 +ildouble: 2 +ldouble: 2 # lgamma Test "lgamma (0.7) == 0.260867246531666514385732417016759578": @@ -453,6 +620,40 @@ double: 1 float: 2 idouble: 1 ifloat: 2 +ildouble: 3 +ldouble: 3 + +# llround +Test "llround (4503599627370496.5) == 4503599627370497LL": +ildouble: -1 +ldouble: -1 +Test "llround (4503599627370497.5) == 4503599627370498LL": +ildouble: -1 +ldouble: -1 +Test "llround (72057594037927935.5) == 72057594037927936LL": +ildouble: -1 +ldouble: -1 +Test "llround (72057594037927936.5) == 72057594037927937LL": +ildouble: -1 +ldouble: -1 +Test "llround (72057594037927936.75) == 72057594037927937LL": +ildouble: -1 +ldouble: -1 +Test "llround (72057594037927937.5) == 72057594037927938LL": +ildouble: -1 +ldouble: -1 +Test "llround (9007199254740991.5) == 9007199254740992LL": +ildouble: -1 +ldouble: -1 +Test "llround (9007199254740992.5) == 9007199254740993LL": +ildouble: -1 +ldouble: -1 +Test "llround (9007199254740992.75) == 9007199254740993LL": +ildouble: -1 +ldouble: -1 +Test "llround (9007199254740993.5) == 9007199254740994LL": +ildouble: -1 +ldouble: -1 # log10 Test "log10 (0.75) == -0.124938736608299953132449886193870744": @@ -469,30 +670,41 @@ Test "log1p (-0.25) == -0.287682072451780927439219005993827432": float: 1 ifloat: 1 +# log2 +Test "log2 (e) == M_LOG2El": +ildouble: 1 +ldouble: 1 + # sincos Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res": double: 1 -float: 1 idouble: 1 -ifloat: 1 Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res": double: 1 float: 1 idouble: 1 ifloat: 1 -Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res": -double: 1 -float: 1 -idouble: 1 -ifloat: 1 Test "sincos (pi/6, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res": float: 1 ifloat: 1 +# sinh +Test "sinh (0.75) == 0.822316731935829980703661634446913849": +ildouble: 1 +ldouble: 1 + # tan Test "tan (pi/4) == 1": -double: 1 -idouble: 1 +ildouble: 1 +ldouble: 1 + +# tanh +Test "tanh (-0.75) == -0.635148952387287319214434357312496495": +ildouble: 1 +ldouble: 1 +Test "tanh (0.75) == 0.635148952387287319214434357312496495": +ildouble: 1 +ldouble: 1 # tgamma Test "tgamma (-0.5) == -2 sqrt (pi)": @@ -510,29 +722,33 @@ idouble: 1 ifloat: 1 # y0 +Test "y0 (0.75) == -0.137172769385772397522814379396581855": +ildouble: 1 +ldouble: 1 Test "y0 (1.0) == 0.0882569642156769579829267660235151628": double: 2 float: 1 idouble: 2 ifloat: 1 +ildouble: 1 +ldouble: 1 Test "y0 (1.5) == 0.382448923797758843955068554978089862": double: 2 float: 1 idouble: 2 ifloat: 1 Test "y0 (10.0) == 0.0556711672835993914244598774101900481": -double: 1 float: 1 -idouble: 1 ifloat: 1 -Test "y0 (2.0) == 0.510375672649745119596606592727157873": -double: 1 -idouble: 1 +ildouble: 17987982955981951215498976719132 +ldouble: 17987982955981951215498976719132 Test "y0 (8.0) == 0.223521489387566220527323400498620359": double: 1 float: 1 idouble: 1 ifloat: 1 +ildouble: 59420910818072525464695270081 +ldouble: 59420910818072525464695270081 # y1 Test "y1 (0.125) == -5.19993611253477499595928744876579921": @@ -546,6 +762,8 @@ double: 3 float: 1 idouble: 3 ifloat: 1 +ildouble: 17166751991147634677444869275635 +ldouble: 17166751991147634677444869275635 Test "y1 (2.0) == -0.107032431540937546888370772277476637": double: 1 float: 1 @@ -556,42 +774,50 @@ double: 1 float: 2 idouble: 1 ifloat: 2 +ildouble: 3843427930176871148105186605483 +ldouble: 3843427930176871148105186605483 # yn +Test "yn (0, 0.75) == -0.137172769385772397522814379396581855": +ildouble: 1 +ldouble: 1 Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628": double: 2 float: 1 idouble: 2 ifloat: 1 +ildouble: 1 +ldouble: 1 Test "yn (0, 1.5) == 0.382448923797758843955068554978089862": double: 2 float: 1 idouble: 2 ifloat: 1 Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481": -double: 1 float: 1 -idouble: 1 ifloat: 1 -Test "yn (0, 2.0) == 0.510375672649745119596606592727157873": -double: 1 -idouble: 1 +ildouble: 17987982955981951215498976719132 +ldouble: 17987982955981951215498976719132 Test "yn (0, 8.0) == 0.223521489387566220527323400498620359": double: 1 float: 1 idouble: 1 ifloat: 1 +ildouble: 59420910818072525464695270081 +ldouble: 59420910818072525464695270081 Test "yn (1, 0.125) == -5.19993611253477499595928744876579921": double: 1 idouble: 1 Test "yn (1, 1.5) == -0.412308626973911295952829820633445323": -float: 2 -ifloat: 2 +float: 1 +ifloat: 1 Test "yn (1, 10.0) == 0.249015424206953883923283474663222803": double: 3 float: 1 idouble: 3 ifloat: 1 +ildouble: 17166751991147634677444869275635 +ldouble: 17166751991147634677444869275635 Test "yn (1, 2.0) == -0.107032431540937546888370772277476637": double: 1 float: 1 @@ -602,9 +828,8 @@ double: 1 float: 2 idouble: 1 ifloat: 2 -Test "yn (3, 0.125) == -2612.69757350066712600220955744091741": -double: 1 -idouble: 1 +ildouble: 3843427930176871148105186605483 +ldouble: 3843427930176871148105186605483 Test "yn (10, 0.125) == -127057845771019398.252538486899753195": double: 1 idouble: 1 @@ -618,14 +843,19 @@ float: 2 ifloat: 2 Test "yn (10, 10.0) == -0.359814152183402722051986577343560609": double: 2 -float: 2 idouble: 2 -ifloat: 2 +ildouble: 799631964554876895122912847384 +ldouble: 799631964554876895122912847384 Test "yn (10, 2.0) == -129184.542208039282635913145923304214": -double: 3 +double: 2 float: 1 -idouble: 3 +idouble: 2 ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "yn (3, 0.125) == -2612.69757350066712600220955744091741": +double: 1 +idouble: 1 Test "yn (3, 0.75) == -12.9877176234475433186319774484809207": float: 1 ifloat: 1 @@ -634,182 +864,286 @@ double: 1 float: 1 idouble: 1 ifloat: 1 +ildouble: 6997306768128814818664001056622 +ldouble: 6997306768128814818664001056622 Test "yn (3, 2.0) == -1.12778377684042778608158395773179238": double: 1 idouble: 1 # Maximal error of functions: +Function: "acos": +ildouble: 1 +ldouble: 1 + +Function: "acosh": +ildouble: 1 +ldouble: 1 + +Function: "asin": +ildouble: 2 +ldouble: 2 + +Function: "asinh": +ildouble: 1 +ldouble: 1 + Function: "atan2": float: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Function: "atanh": float: 1 ifloat: 1 +Function: "cabs": +ildouble: 1 +ldouble: 1 + +Function: Real part of "cacos": +ildouble: 1 +ldouble: 1 + +Function: Imaginary part of "cacos": +ildouble: 1 +ldouble: 1 + Function: Real part of "cacosh": -double: 1 -float: 7 -idouble: 1 -ifloat: 7 +ildouble: 1 +ldouble: 1 Function: Imaginary part of "cacosh": -double: 1 -float: 3 -idouble: 1 -ifloat: 3 +float: 1 +ifloat: 1 Function: Real part of "casin": double: 1 float: 1 idouble: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: Imaginary part of "casin": +ildouble: 1 +ldouble: 1 Function: Real part of "casinh": double: 5 float: 1 idouble: 5 ifloat: 1 +ildouble: 4 +ldouble: 4 Function: Imaginary part of "casinh": double: 3 float: 6 idouble: 3 ifloat: 6 +ildouble: 1 +ldouble: 1 Function: Real part of "catan": -float: 4 -ifloat: 4 +ildouble: 1 +ldouble: 1 Function: Imaginary part of "catan": double: 1 float: 1 idouble: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Function: Real part of "catanh": double: 4 idouble: 4 -Function: Imaginary part of "catanh": -float: 6 -ifloat: 6 - Function: "cbrt": double: 1 idouble: 1 +ildouble: 1 +ldouble: 1 Function: Real part of "ccos": double: 1 float: 1 idouble: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Function: Imaginary part of "ccos": float: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Function: Real part of "ccosh": double: 1 float: 1 idouble: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Function: Imaginary part of "ccosh": float: 1 ifloat: 1 +ildouble: 2 +ldouble: 2 Function: Real part of "cexp": float: 1 ifloat: 1 +ildouble: 2 +ldouble: 2 Function: Imaginary part of "cexp": float: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Function: Real part of "clog": float: 1 ifloat: 1 +ildouble: 2 +ldouble: 2 Function: Imaginary part of "clog": -float: 3 -ifloat: 3 +ildouble: 1 +ldouble: 1 Function: Real part of "clog10": float: 1 ifloat: 1 +ildouble: 2 +ldouble: 2 Function: Imaginary part of "clog10": double: 1 -float: 5 +float: 1 idouble: 1 -ifloat: 5 +ifloat: 1 +ildouble: 1 +ldouble: 1 Function: "cos": double: 2 float: 1 idouble: 2 ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "cosh": +ildouble: 1 +ldouble: 1 Function: Real part of "cpow": double: 2 float: 5 idouble: 2 ifloat: 5 +ildouble: 2 +ldouble: 2 Function: Imaginary part of "cpow": double: 2 float: 2 idouble: 2 ifloat: 2 +ildouble: 2 +ldouble: 2 + +Function: Imaginary part of "cproj": +ildouble: 1 +ldouble: 1 + +Function: Real part of "csin": +ildouble: 1 +ldouble: 1 Function: Real part of "csinh": float: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Function: Imaginary part of "csinh": double: 1 float: 1 idouble: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Function: Real part of "csqrt": float: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: Imaginary part of "csqrt": +ildouble: 1 +ldouble: 1 Function: Real part of "ctan": -double: 1 -idouble: 1 +ildouble: 1 +ldouble: 1 Function: Imaginary part of "ctan": double: 1 idouble: 1 +ildouble: 1 +ldouble: 1 Function: Real part of "ctanh": double: 1 float: 2 idouble: 1 ifloat: 2 +ildouble: 1 +ldouble: 1 Function: Imaginary part of "ctanh": float: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Function: "erf": double: 1 idouble: 1 +ildouble: 1 +ldouble: 1 Function: "erfc": double: 1 float: 1 idouble: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "exp": +ildouble: 1 +ldouble: 1 Function: "exp10": double: 6 float: 2 idouble: 6 ifloat: 2 +ildouble: 8 +ldouble: 8 + +Function: "exp2": +ildouble: 2 +ldouble: 2 Function: "expm1": double: 1 @@ -817,76 +1151,130 @@ float: 1 idouble: 1 ifloat: 1 +Function: "gamma": +ildouble: 1 +ldouble: 1 + Function: "hypot": float: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Function: "j0": -double: 3 +double: 2 float: 2 -idouble: 3 +idouble: 2 ifloat: 2 +ildouble: 38324122909174090074461780712157 +ldouble: 38324122909174090074461780712157 Function: "j1": double: 1 float: 2 idouble: 1 ifloat: 2 +ildouble: 21475644881377747614143400473061 +ldouble: 21475644881377747614143400473061 Function: "jn": double: 3 float: 4 idouble: 3 ifloat: 4 +ildouble: 47549060992978485557887362065694 +ldouble: 47549060992978485557887362065694 Function: "lgamma": double: 1 float: 2 idouble: 1 ifloat: 2 +ildouble: 3 +ldouble: 3 + +Function: "log": +ildouble: 1 +ldouble: 1 Function: "log10": double: 1 float: 2 idouble: 1 ifloat: 2 +ildouble: 1 +ldouble: 1 Function: "log1p": float: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "log2": +ildouble: 1 +ldouble: 1 + +Function: "pow": +ildouble: 1 +ldouble: 1 + +Function: "sin": +ildouble: 1 +ldouble: 1 Function: "sincos": double: 1 float: 1 idouble: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 + +Function: "sinh": +ildouble: 1 +ldouble: 1 Function: "tan": double: 1 idouble: 1 +ildouble: 1 +ldouble: 1 + +Function: "tanh": +ildouble: 1 +ldouble: 1 Function: "tgamma": double: 1 float: 1 idouble: 1 ifloat: 1 +ildouble: 1 +ldouble: 1 Function: "y0": double: 2 float: 1 idouble: 2 ifloat: 1 +ildouble: 17987982955981951215498976719132 +ldouble: 17987982955981951215498976719132 Function: "y1": double: 3 float: 2 idouble: 3 ifloat: 2 +ildouble: 3843427930176871148105186605483 +ldouble: 3843427930176871148105186605483 Function: "yn": double: 3 float: 2 idouble: 3 ifloat: 2 +ildouble: 3843427930176871148105186605483 +ldouble: 3843427930176871148105186605483 # end of automatic generation diff --git a/sysdeps/powerpc/fpu/s_isnan.c b/sysdeps/powerpc/fpu/s_isnan.c index 38ec821..f3313c7 100644 --- a/sysdeps/powerpc/fpu/s_isnan.c +++ b/sysdeps/powerpc/fpu/s_isnan.c @@ -1,5 +1,5 @@ /* Return 1 if argument is a NaN, else 0. - Copyright (C) 1997, 2000, 2002 Free Software Foundation, Inc. + Copyright (C) 1997, 2000, 2002, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -23,6 +23,7 @@ #define __GI___isnanf __GI___Xisnanf #include "math.h" +#include #include #undef __isnanf diff --git a/sysdeps/powerpc/powerpc32/Implies b/sysdeps/powerpc/powerpc32/Implies index 9ef3ac1..39a34c5 100644 --- a/sysdeps/powerpc/powerpc32/Implies +++ b/sysdeps/powerpc/powerpc32/Implies @@ -1,2 +1 @@ wordsize-32 -powerpc/soft-fp diff --git a/sysdeps/powerpc/powerpc32/fpu/s_ceil.S b/sysdeps/powerpc/powerpc32/fpu/s_ceil.S index 2e0e6a8..bc74d30 100644 --- a/sysdeps/powerpc/powerpc32/fpu/s_ceil.S +++ b/sysdeps/powerpc/powerpc32/fpu/s_ceil.S @@ -18,6 +18,7 @@ 02110-1301 USA. */ #include +#include .section .rodata.cst4,"aM",@progbits,4 .align 2 @@ -77,3 +78,6 @@ weak_alias (__ceil, ceil) weak_alias (__ceil, ceill) strong_alias (__ceil, __ceill) #endif +#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0) +compat_symbol (libm, __ceil, ceill, GLIBC_2_0) +#endif diff --git a/sysdeps/powerpc/powerpc32/fpu/s_copysign.S b/sysdeps/powerpc/powerpc32/fpu/s_copysign.S index 39d7d1c..dd68b08 100644 --- a/sysdeps/powerpc/powerpc32/fpu/s_copysign.S +++ b/sysdeps/powerpc/powerpc32/fpu/s_copysign.S @@ -21,6 +21,7 @@ when it's coded in C. */ #include +#include ENTRY(__copysign) /* double [f1] copysign (double [f1] x, double [f2] y); @@ -32,6 +33,7 @@ ENTRY(__copysign) lwz r3,8(r1) cmpwi r3,0 addi r1,r1,16 + cfi_adjust_cfa_offset (-16) blt L(0) fabs fp1,fp1 blr @@ -49,3 +51,10 @@ strong_alias(__copysign,__copysignf) weak_alias (__copysign,copysignl) strong_alias(__copysign,__copysignl) #endif +#ifdef IS_IN_libm +# if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0) +compat_symbol (libm, __copysign, copysignl, GLIBC_2_0) +# endif +#elif LONG_DOUBLE_COMPAT(libc, GLIBC_2_0) +compat_symbol (libc, __copysign, copysignl, GLIBC_2_0) +#endif diff --git a/sysdeps/powerpc/powerpc32/fpu/s_copysignl.S b/sysdeps/powerpc/powerpc32/fpu/s_copysignl.S new file mode 100644 index 0000000..64b6a45 --- /dev/null +++ b/sysdeps/powerpc/powerpc32/fpu/s_copysignl.S @@ -0,0 +1,50 @@ +/* Copy a sign bit between floating-point values. + IBM extended format long double version. + Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +ENTRY(__copysignl) +/* long double [f1,f2] copysign (long double [f1,f2] x, long double [f3,f4] y); + copysign(x,y) returns a value with the magnitude of x and + with the sign bit of y. */ + stwu r1,-16(r1) + cfi_adjust_cfa_offset (16) + stfd fp3,8(r1) + fmr fp0,fp1 + fabs fp1,fp1 + fcmpu cr7,fp0,fp1 + lwz r3,8(r1) + cmpwi cr6,r3,0 + addi r1,r1,16 + cfi_adjust_cfa_offset (-16) + beq cr7,L(0) + fneg fp2,fp2 +L(0): bgelr cr6 + fneg fp1,fp1 + fneg fp2,fp2 + blr +END (__copysignl) + +#ifdef IS_IN_libm +long_double_symbol (libm, __copysignl, copysignl) +#else +long_double_symbol (libc, __copysignl, copysignl) +#endif diff --git a/sysdeps/powerpc/powerpc32/fpu/s_fabs.S b/sysdeps/powerpc/powerpc32/fpu/s_fabs.S new file mode 100644 index 0000000..53d2130 --- /dev/null +++ b/sysdeps/powerpc/powerpc32/fpu/s_fabs.S @@ -0,0 +1,5 @@ +#include +#include +#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0) +compat_symbol (libm, __fabs, fabsl, GLIBC_2_0) +#endif diff --git a/sysdeps/powerpc/powerpc32/fpu/s_fabsl.S b/sysdeps/powerpc/powerpc32/fpu/s_fabsl.S new file mode 100644 index 0000000..3655e5b --- /dev/null +++ b/sysdeps/powerpc/powerpc32/fpu/s_fabsl.S @@ -0,0 +1,36 @@ +/* Copy a sign bit between floating-point values. + IBM extended format long double version. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +ENTRY(__fabsl) +/* long double [f1,f2] fabs (long double [f1,f2] x); + fabs(x,y) returns a value with the magnitude of x and + with the sign bit of y. */ + fmr fp0,fp1 + fabs fp1,fp1 + fcmpu cr1,fp0,fp1 + beqlr cr1 + fneg fp2,fp2 + blr +END (__fabsl) + +long_double_symbol (libm, __fabsl, fabsl) diff --git a/sysdeps/powerpc/powerpc32/fpu/s_fdim.c b/sysdeps/powerpc/powerpc32/fpu/s_fdim.c new file mode 100644 index 0000000..e34b51e --- /dev/null +++ b/sysdeps/powerpc/powerpc32/fpu/s_fdim.c @@ -0,0 +1,5 @@ +#include +#include +#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1) +compat_symbol (libm, __fdim, fdiml, GLIBC_2_1); +#endif diff --git a/sysdeps/powerpc/powerpc32/fpu/s_floor.S b/sysdeps/powerpc/powerpc32/fpu/s_floor.S index 5942d09..a29e479 100644 --- a/sysdeps/powerpc/powerpc32/fpu/s_floor.S +++ b/sysdeps/powerpc/powerpc32/fpu/s_floor.S @@ -18,6 +18,7 @@ 02110-1301 USA. */ #include +#include .section .rodata.cst4,"aM",@progbits,4 .align 2 @@ -77,3 +78,6 @@ weak_alias (__floor, floor) weak_alias (__floor, floorl) strong_alias (__floor, __floorl) #endif +#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0) +compat_symbol (libm, __floor, floorl, GLIBC_2_0) +#endif diff --git a/sysdeps/powerpc/powerpc32/fpu/s_fmax.S b/sysdeps/powerpc/powerpc32/fpu/s_fmax.S new file mode 100644 index 0000000..6973576 --- /dev/null +++ b/sysdeps/powerpc/powerpc32/fpu/s_fmax.S @@ -0,0 +1,5 @@ +#include +#include +#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1) +compat_symbol (libm, __fmax, fmaxl, GLIBC_2_1) +#endif diff --git a/sysdeps/powerpc/powerpc32/fpu/s_fmin.S b/sysdeps/powerpc/powerpc32/fpu/s_fmin.S new file mode 100644 index 0000000..6d4a0a9 --- /dev/null +++ b/sysdeps/powerpc/powerpc32/fpu/s_fmin.S @@ -0,0 +1,5 @@ +#include +#include +#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1) +compat_symbol (libm, __fmin, fminl, GLIBC_2_1) +#endif diff --git a/sysdeps/powerpc/powerpc32/fpu/s_isnan.c b/sysdeps/powerpc/powerpc32/fpu/s_isnan.c new file mode 100644 index 0000000..397717b --- /dev/null +++ b/sysdeps/powerpc/powerpc32/fpu/s_isnan.c @@ -0,0 +1,7 @@ +#include +#ifndef IS_IN_libm +# if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0) +compat_symbol (libc, __isnan, __isnanl, GLIBC_2_0); +compat_symbol (libc, isnan, isnanl, GLIBC_2_0); +# endif +#endif diff --git a/sysdeps/powerpc/powerpc32/fpu/s_llrint.c b/sysdeps/powerpc/powerpc32/fpu/s_llrint.c index 7fdc296..cb96be7 100644 --- a/sysdeps/powerpc/powerpc32/fpu/s_llrint.c +++ b/sysdeps/powerpc/powerpc32/fpu/s_llrint.c @@ -1,5 +1,5 @@ /* Round a double value to a long long in the current rounding mode. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -17,7 +17,8 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include "math.h" +#include +#include long long int __llrint (double x) @@ -29,3 +30,6 @@ weak_alias (__llrint, llrint) strong_alias (__llrint, __llrintl) weak_alias (__llrint, llrintl) #endif +#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1) +compat_symbol (libm, __llrint, llrintl, GLIBC_2_1); +#endif diff --git a/sysdeps/powerpc/powerpc32/fpu/s_lrint.S b/sysdeps/powerpc/powerpc32/fpu/s_lrint.S index 57d56c4..55e9de7 100644 --- a/sysdeps/powerpc/powerpc32/fpu/s_lrint.S +++ b/sysdeps/powerpc/powerpc32/fpu/s_lrint.S @@ -1,5 +1,5 @@ /* Round double to long int. PowerPC32 version. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -18,6 +18,7 @@ 02111-1307 USA. */ #include +#include /* long int[r3] __lrint (double x[fp1]) */ ENTRY (__lrint) @@ -39,3 +40,6 @@ weak_alias (__lrint, lrintf) strong_alias (__lrint, __lrintl) weak_alias (__lrint, lrintl) #endif +#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1) +compat_symbol (libm, __lrint, lrintl, GLIBC_2_1) +#endif diff --git a/sysdeps/powerpc/powerpc32/fpu/s_lround.S b/sysdeps/powerpc/powerpc32/fpu/s_lround.S index 67e5884..9c534ec 100644 --- a/sysdeps/powerpc/powerpc32/fpu/s_lround.S +++ b/sysdeps/powerpc/powerpc32/fpu/s_lround.S @@ -18,6 +18,7 @@ 02110-1301 USA. */ #include +#include .section .rodata.cst8,"aM",@progbits,8 .align 2 @@ -93,3 +94,6 @@ weak_alias (__lround, lroundf) weak_alias (__lround, lroundl) strong_alias (__lround, __lroundl) #endif +#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1) +compat_symbol (libm, __lround, lroundl, GLIBC_2_1) +#endif diff --git a/sysdeps/powerpc/powerpc32/fpu/s_rint.S b/sysdeps/powerpc/powerpc32/fpu/s_rint.S index 041cb58..c8dca31 100644 --- a/sysdeps/powerpc/powerpc32/fpu/s_rint.S +++ b/sysdeps/powerpc/powerpc32/fpu/s_rint.S @@ -21,6 +21,7 @@ when it's coded in C. */ #include +#include .section .rodata.cst4,"aM",@progbits,4 .align 2 @@ -73,3 +74,6 @@ weak_alias (__rint, rint) weak_alias (__rint, rintl) strong_alias (__rint, __rintl) #endif +#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0) +compat_symbol (libm, __rint, rintl, GLIBC_2_0) +#endif diff --git a/sysdeps/powerpc/powerpc32/fpu/s_round.S b/sysdeps/powerpc/powerpc32/fpu/s_round.S index 04ba942..590c87a 100644 --- a/sysdeps/powerpc/powerpc32/fpu/s_round.S +++ b/sysdeps/powerpc/powerpc32/fpu/s_round.S @@ -18,6 +18,7 @@ 02110-1301 USA. */ #include +#include .section .rodata.cst8,"aM",@progbits,8 .align 2 @@ -97,3 +98,6 @@ weak_alias (__round, round) weak_alias (__round, roundl) strong_alias (__round, __roundl) #endif +#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1) +compat_symbol (libm, __round, roundl, GLIBC_2_1) +#endif diff --git a/sysdeps/powerpc/powerpc32/fpu/s_trunc.S b/sysdeps/powerpc/powerpc32/fpu/s_trunc.S index 4ea4e07..5bc0856 100644 --- a/sysdeps/powerpc/powerpc32/fpu/s_trunc.S +++ b/sysdeps/powerpc/powerpc32/fpu/s_trunc.S @@ -18,6 +18,7 @@ 02110-1301 USA. */ #include +#include .section .rodata.cst4,"aM",@progbits,4 .align 2 @@ -65,7 +66,7 @@ ENTRY (__trunc) fsub fp1,fp1,fp13 /* x-= TWO52; */ fabs fp1,fp1 /* if (x == 0.0) */ /* x = 0.0; */ - mtfsf 0x01,fp11 /* restore previous truncing mode. */ + mtfsf 0x01,fp11 /* restore previous rounding mode. */ blr .L4: bge- cr6,.L9 /* if (x < 0.0) */ @@ -84,3 +85,6 @@ weak_alias (__trunc, trunc) weak_alias (__trunc, truncl) strong_alias (__trunc, __truncl) #endif +#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1) +compat_symbol (libm, __trunc, truncl, GLIBC_2_1) +#endif diff --git a/sysdeps/powerpc/powerpc32/fpu/s_truncf.S b/sysdeps/powerpc/powerpc32/fpu/s_truncf.S index 0005d50..e2e3bd6 100644 --- a/sysdeps/powerpc/powerpc32/fpu/s_truncf.S +++ b/sysdeps/powerpc/powerpc32/fpu/s_truncf.S @@ -65,7 +65,7 @@ ENTRY (__truncf) fsubs fp1,fp1,fp13 /* x-= TWO23; */ fabs fp1,fp1 /* if (x == 0.0) */ /* x = 0.0; */ - mtfsf 0x01,fp11 /* restore previous truncing mode. */ + mtfsf 0x01,fp11 /* restore previous rounding mode. */ blr .L4: bge- cr6,.L9 /* if (x < 0.0) */ diff --git a/sysdeps/powerpc/powerpc64/fpu/s_ceil.S b/sysdeps/powerpc/powerpc64/fpu/s_ceil.S index 9809e24..02b7094 100644 --- a/sysdeps/powerpc/powerpc64/fpu/s_ceil.S +++ b/sysdeps/powerpc/powerpc64/fpu/s_ceil.S @@ -1,5 +1,5 @@ /* ceil function. PowerPC64 version. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -18,6 +18,7 @@ 02111-1307 USA. */ #include +#include .section ".toc","aw" .LC0: /* 2**52 */ @@ -58,3 +59,6 @@ weak_alias (__ceil, ceil) weak_alias (__ceil, ceill) strong_alias (__ceil, __ceill) #endif +#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0) +compat_symbol (libm, __ceil, ceill, GLIBC_2_0) +#endif diff --git a/sysdeps/powerpc/powerpc64/fpu/s_ceill.S b/sysdeps/powerpc/powerpc64/fpu/s_ceill.S new file mode 100644 index 0000000..e164fec --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_ceill.S @@ -0,0 +1,133 @@ +/* s_ceill.S IBM extended format long double version. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + + .section ".toc","aw" +.LC0: /* 2**52 */ + .tc FD_43300000_0[TC],0x4330000000000000 + + .section ".text" + +/* long double [fp1,fp2] ceill (long double x [fp1,fp2]) + IEEE 1003.1 ceil function. + + PowerPC64 long double uses the IBM extended format which is + represented two 64-floating point double values. The values are + non-overlapping giving an effective precision of 106 bits. The first + double contains the high order bits of mantisa and is always ceiled + to represent a normal ceiling of long double to double. Since the + long double value is sum of the high and low values, the low double + normally has the opposite sign to compensate for the this ceiling. + + For long double there are two cases: + 1) |x| < 2**52, all the integer bits are in the high double. + ceil the high double and set the low double to -0.0. + 2) |x| >= 2**52, ceiling involves both doubles. + See the comment before lable .L2 for details. + */ + +ENTRY (__ceill) + mffs fp11 /* Save current FPU rounding mode. */ + lfd fp13,.LC0@toc(2) + fabs fp0,fp1 + fabs fp9,fp2 + fsub fp12,fp13,fp13 /* generate 0.0 */ + fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO52) */ + fcmpo cr6,fp1,fp12 /* if (x > 0.0) */ + bnl- cr7,.L2 + mtfsfi 7,2 /* Set rounding mode toward +inf. */ + fneg fp2,fp12 + ble- cr6,.L1 + fadd fp1,fp1,fp13 /* x+= TWO52; */ + fsub fp1,fp1,fp13 /* x-= TWO52; */ + fabs fp1,fp1 /* if (x == 0.0) */ +.L0: + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + blr /* x = 0.0; */ +.L1: + bge- cr6,.L0 /* if (x < 0.0) */ + fsub fp1,fp1,fp13 /* x-= TWO52; */ + fadd fp1,fp1,fp13 /* x+= TWO52; */ + fcmpu cr5,fp1,fp12 /* if (x > 0.0) */ + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + fnabs fp1,fp1 /* if (x == 0.0) */ + blr /* x = -0.0; */ + +/* The high double is > TWO52 so we need to round the low double and + perhaps the high double. In this case we have to round the low + double and handle any adjustment to the high double that may be + caused by rounding (up). This is complicated by the fact that the + high double may already be rounded and the low double may have the + opposite sign to compensate.This gets a bit tricky so we use the + following algorithm: + + tau = floor(x_high/TWO52); + x0 = x_high - tau; + x1 = x_low + tau; + r1 = rint(x1); + y_high = x0 + r1; + y_low = x0 - y_high + r1; + return y; */ +.L2: + fcmpu cr7,fp9,fp13 /* if (|x_low| > TWO52) */ + fcmpu cr0,fp9,fp12 /* || (|x_low| == 0.0) */ + fcmpu cr5,fp2,fp12 /* if (x_low > 0.0) */ + bgelr- cr7 /* return x; */ + beqlr- cr0 + mtfsfi 7,2 /* Set rounding mode toward +inf. */ + fdiv fp8,fp1,fp13 /* x_high/TWO52 */ + + bng- cr6,.L6 /* if (x > 0.0) */ + fctidz fp0,fp8 + fcfid fp8,fp0 /* tau = floor(x_high/TWO52); */ + bng cr5,.L4 /* if (x_low > 0.0) */ + fmr fp3,fp1 + fmr fp4,fp2 + b .L5 +.L4: /* if (x_low < 0.0) */ + fsub fp3,fp1,fp8 /* x0 = x_high - tau; */ + fadd fp4,fp2,fp8 /* x1 = x_low + tau; */ +.L5: + fadd fp5,fp4,fp13 /* r1 = r1 + TWO52; */ + fsub fp5,fp5,fp13 /* r1 = r1 - TWO52; */ + b .L9 +.L6: /* if (x < 0.0) */ + fctidz fp0,fp8 + fcfid fp8,fp0 /* tau = floor(x_high/TWO52); */ + bnl cr5,.L7 /* if (x_low < 0.0) */ + fmr fp3,fp1 + fmr fp4,fp2 + b .L8 +.L7: /* if (x_low > 0.0) */ + fsub fp3,fp1,fp8 /* x0 = x_high - tau; */ + fadd fp4,fp2,fp8 /* x1 = x_low + tau; */ +.L8: + fsub fp5,fp4,fp13 /* r1-= TWO52; */ + fadd fp5,fp5,fp13 /* r1+= TWO52; */ +.L9: + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + fadd fp1,fp3,fp5 /* y_high = x0 + r1; */ + fsub fp2,fp3,fp1 /* y_low = x0 - y_high + r1; */ + fadd fp2,fp2,fp5 + blr +END (__ceill) + +long_double_symbol (libm, __ceill, ceill) diff --git a/sysdeps/powerpc/powerpc64/fpu/s_copysign.S b/sysdeps/powerpc/powerpc64/fpu/s_copysign.S index c0fdf41..38171e3 100644 --- a/sysdeps/powerpc/powerpc64/fpu/s_copysign.S +++ b/sysdeps/powerpc/powerpc64/fpu/s_copysign.S @@ -1,5 +1,5 @@ /* Copy a sign bit between floating-point values. PowerPC64 version. - Copyright (C) 1997, 1999, 2000, 2002 Free Software Foundation, Inc. + Copyright (C) 1997, 1999, 2000, 2002, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -21,6 +21,7 @@ when it's coded in C. */ #include +#include ENTRY(__copysign) CALL_MCOUNT 0 @@ -53,3 +54,10 @@ strong_alias(__copysign,__copysignf) weak_alias (__copysign,copysignl) strong_alias(__copysign,__copysignl) #endif +#ifdef IS_IN_libm +# if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0) +compat_symbol (libm, __copysign, copysignl, GLIBC_2_0) +# endif +#elif LONG_DOUBLE_COMPAT(libc, GLIBC_2_0) +compat_symbol (libc, __copysign, copysignl, GLIBC_2_0) +#endif diff --git a/sysdeps/powerpc/powerpc64/fpu/s_copysignl.S b/sysdeps/powerpc/powerpc64/fpu/s_copysignl.S new file mode 100644 index 0000000..b2c62ea --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_copysignl.S @@ -0,0 +1,51 @@ +/* Copy a sign bit between floating-point values. + IBM extended format long double version. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +ENTRY(__copysignl) +/* long double [f1,f2] copysign (long double [f1,f2] x, long double [f3,f4] y); + copysign(x,y) returns a value with the magnitude of x and + with the sign bit of y. */ + stfd fp3,-16(r1) + ld r3,-16(r1) + cmpdi r3,0 + blt L(0) + fmr fp0,fp1 + fabs fp1,fp1 + fcmpu cr1,fp0,fp1 + beqlr cr1 + fneg fp2,fp2 + blr +L(0): + fmr fp0,fp1 + fnabs fp1,fp1 + fcmpu cr1,fp0,fp1 + beqlr cr1 + fneg fp2,fp2 + blr +END (__copysignl) + +#ifdef IS_IN_libm +long_double_symbol (libm, __copysignl, copysignl) +#else +long_double_symbol (libc, __copysignl, copysignl) +#endif diff --git a/sysdeps/powerpc/powerpc64/fpu/s_fabs.S b/sysdeps/powerpc/powerpc64/fpu/s_fabs.S new file mode 100644 index 0000000..53d2130 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_fabs.S @@ -0,0 +1,5 @@ +#include +#include +#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0) +compat_symbol (libm, __fabs, fabsl, GLIBC_2_0) +#endif diff --git a/sysdeps/powerpc/powerpc64/fpu/s_fabsl.S b/sysdeps/powerpc/powerpc64/fpu/s_fabsl.S new file mode 100644 index 0000000..3655e5b --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_fabsl.S @@ -0,0 +1,36 @@ +/* Copy a sign bit between floating-point values. + IBM extended format long double version. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +ENTRY(__fabsl) +/* long double [f1,f2] fabs (long double [f1,f2] x); + fabs(x,y) returns a value with the magnitude of x and + with the sign bit of y. */ + fmr fp0,fp1 + fabs fp1,fp1 + fcmpu cr1,fp0,fp1 + beqlr cr1 + fneg fp2,fp2 + blr +END (__fabsl) + +long_double_symbol (libm, __fabsl, fabsl) diff --git a/sysdeps/powerpc/powerpc64/fpu/s_fdim.c b/sysdeps/powerpc/powerpc64/fpu/s_fdim.c new file mode 100644 index 0000000..e34b51e --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_fdim.c @@ -0,0 +1,5 @@ +#include +#include +#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1) +compat_symbol (libm, __fdim, fdiml, GLIBC_2_1); +#endif diff --git a/sysdeps/powerpc/powerpc64/fpu/s_floor.S b/sysdeps/powerpc/powerpc64/fpu/s_floor.S index 183423c..65a2848 100644 --- a/sysdeps/powerpc/powerpc64/fpu/s_floor.S +++ b/sysdeps/powerpc/powerpc64/fpu/s_floor.S @@ -1,5 +1,5 @@ /* Floor function. PowerPC64 version. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -18,6 +18,7 @@ 02111-1307 USA. */ #include +#include .section ".toc","aw" .LC0: /* 2**52 */ @@ -58,3 +59,6 @@ weak_alias (__floor, floor) weak_alias (__floor, floorl) strong_alias (__floor, __floorl) #endif +#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0) +compat_symbol (libm, __floor, floorl, GLIBC_2_0) +#endif diff --git a/sysdeps/powerpc/powerpc64/fpu/s_floorl.S b/sysdeps/powerpc/powerpc64/fpu/s_floorl.S new file mode 100644 index 0000000..01b3c21 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_floorl.S @@ -0,0 +1,134 @@ +/* long double floor function. + IBM extended format long double version. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + + .section ".toc","aw" +.LC0: /* 2**52 */ + .tc FD_43300000_0[TC],0x4330000000000000 + + .section ".text" +/* long double [fp1,fp2] floorl (long double x [fp1,fp2]) + IEEE 1003.1 floor function. + + PowerPC64 long double uses the IBM extended format which is + represented two 64-floating point double values. The values are + non-overlapping giving an effective precision of 106 bits. The first + double contains the high order bits of mantisa and is always rounded + to represent a normal rounding of long double to double. Since the + long double value is sum of the high and low values, the low double + normally has the opposite sign to compensate for the this rounding. + + For long double there are two cases: + 1) |x| < 2**52, all the integer bits are in the high double. + floor the high double and set the low double to -0.0. + 2) |x| >= 2**52, Rounding involves both doubles. + See the comment before lable .L2 for details. + */ + +ENTRY (__floorl) + mffs fp11 /* Save current FPU rounding mode. */ + lfd fp13,.LC0@toc(2) + fabs fp0,fp1 + fabs fp9,fp2 + fsub fp12,fp13,fp13 /* generate 0.0 */ + fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO52) */ + fcmpu cr6,fp1,fp12 /* if (x > 0.0) */ + bnl- cr7,.L2 + mtfsfi 7,3 /* Set rounding mode toward -inf. */ + fneg fp2,fp12 /* set low double to -0.0. */ + ble- cr6,.L0 + fadd fp1,fp1,fp13 /* x+= TWO52; */ + fsub fp1,fp1,fp13 /* x-= TWO52; */ + fcmpu cr5,fp1,fp12 /* if (x > 0.0) */ + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + bnelr+ cr5 + fmr fp1,fp12 /* x must be +0.0 for the 0.0 case. */ + blr +.L0: + bge- cr6,.L1 /* if (x < 0.0) */ + fsub fp1,fp1,fp13 /* x-= TWO52; */ + fadd fp1,fp1,fp13 /* x+= TWO52; */ +.L1: + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + blr + + +/* The high double is > TWO52 so we need to round the low double and + perhaps the high double. In this case we have to round the low + double and handle any adjustment to the high double that may be + caused by rounding (up). This is complicated by the fact that the + high double may already be rounded and the low double may have the + opposite sign to compensate.This gets a bit tricky so we use the + following algorithm: + + tau = floor(x_high/TWO52); + x0 = x_high - tau; + x1 = x_low + tau; + r1 = rint(x1); + y_high = x0 + r1; + y_low = x0 - y_high + r1; + return y; */ +.L2: + fcmpu cr7,fp9,fp13 /* if (|x_low| > TWO52) */ + fcmpu cr0,fp9,fp12 /* || (|x_low| == 0.0) */ + fcmpu cr5,fp2,fp12 /* if (x_low > 0.0) */ + bgelr- cr7 /* return x; */ + beqlr- cr0 + mtfsfi 7,3 /* Set rounding mode toward -inf. */ + fdiv fp8,fp1,fp13 /* x_high/TWO52 */ + + bng- cr6,.L6 /* if (x > 0.0) */ + fctidz fp0,fp8 + fcfid fp8,fp0 /* tau = floor(x_high/TWO52); */ + bng cr5,.L4 /* if (x_low > 0.0) */ + fmr fp3,fp1 + fmr fp4,fp2 + b .L5 +.L4: /* if (x_low < 0.0) */ + fsub fp3,fp1,fp8 /* x0 = x_high - tau; */ + fadd fp4,fp2,fp8 /* x1 = x_low + tau; */ +.L5: + fadd fp5,fp4,fp13 /* r1 = r1 + TWO52; */ + fsub fp5,fp5,fp13 /* r1 = r1 - TWO52; */ + b .L9 +.L6: /* if (x < 0.0) */ + fctidz fp0,fp8 + fcfid fp8,fp0 /* tau = floor(x_high/TWO52); */ + bnl cr5,.L7 /* if (x_low < 0.0) */ + fmr fp3,fp1 + fmr fp4,fp2 + b .L8 +.L7: /* if (x_low > 0.0) */ + fsub fp3,fp1,fp8 /* x0 = x_high - tau; */ + fadd fp4,fp2,fp8 /* x1 = x_low + tau; */ +.L8: + fsub fp5,fp4,fp13 /* r1-= TWO52; */ + fadd fp5,fp5,fp13 /* r1+= TWO52; */ +.L9: + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + fadd fp1,fp3,fp5 /* y_high = x0 + r1; */ + fsub fp2,fp3,fp1 /* y_low = x0 - y_high + r1; */ + fadd fp2,fp2,fp5 + blr +END (__floorl) + +long_double_symbol (libm, __floorl, floorl) diff --git a/sysdeps/powerpc/powerpc64/fpu/s_fmax.S b/sysdeps/powerpc/powerpc64/fpu/s_fmax.S new file mode 100644 index 0000000..6973576 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_fmax.S @@ -0,0 +1,5 @@ +#include +#include +#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1) +compat_symbol (libm, __fmax, fmaxl, GLIBC_2_1) +#endif diff --git a/sysdeps/powerpc/powerpc64/fpu/s_fmin.S b/sysdeps/powerpc/powerpc64/fpu/s_fmin.S new file mode 100644 index 0000000..6d4a0a9 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_fmin.S @@ -0,0 +1,5 @@ +#include +#include +#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1) +compat_symbol (libm, __fmin, fminl, GLIBC_2_1) +#endif diff --git a/sysdeps/powerpc/powerpc64/fpu/s_isnan.c b/sysdeps/powerpc/powerpc64/fpu/s_isnan.c new file mode 100644 index 0000000..397717b --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_isnan.c @@ -0,0 +1,7 @@ +#include +#ifndef IS_IN_libm +# if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0) +compat_symbol (libc, __isnan, __isnanl, GLIBC_2_0); +compat_symbol (libc, isnan, isnanl, GLIBC_2_0); +# endif +#endif diff --git a/sysdeps/powerpc/powerpc64/fpu/s_llrint.S b/sysdeps/powerpc/powerpc64/fpu/s_llrint.S index 610b561..ff0ba94 100644 --- a/sysdeps/powerpc/powerpc64/fpu/s_llrint.S +++ b/sysdeps/powerpc/powerpc64/fpu/s_llrint.S @@ -1,5 +1,5 @@ /* Round double to long int. PowerPC64 version. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -18,6 +18,7 @@ 02111-1307 USA. */ #include +#include /* long long int[r3] __llrint (double x[fp1]) */ ENTRY (__llrint) @@ -41,3 +42,7 @@ weak_alias (__llrint, llrintl) strong_alias (__lrint, __lrintl) weak_alias (__lrint, lrintl) #endif +#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1) +compat_symbol (libm, __llrint, llrintl, GLIBC_2_1) +compat_symbol (libm, __lrint, lrintl, GLIBC_2_1) +#endif diff --git a/sysdeps/powerpc/powerpc64/fpu/s_llrintl.S b/sysdeps/powerpc/powerpc64/fpu/s_llrintl.S new file mode 100644 index 0000000..aa48777 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_llrintl.S @@ -0,0 +1,94 @@ +/* Round long double to long int. + IBM extended format long double version. + Copyright (C) 2004,2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + + .section ".toc","aw" +.LC0: /* 2**52 */ + .tc FD_43300000_0[TC],0x4330000000000000 +.LC1: /* 2**63 */ + .tc FD_43E00000_0[TC],0x43e0000000000000 + .section ".text" + +/* long long int[r3] __llrintl (long double x[fp1,fp2]) */ +ENTRY (__llrintl) + lfd fp13,.LC0@toc(2) + lfd fp10,.LC1@toc(2) + fabs fp0,fp1 + fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO52) */ + fcmpu cr6,fp0,fp10 /* if (fabs(x) > TWO63) */ + beq- cr6,.L2 + fctid fp11,fp1 /* must delay this opperation to here */ + fctid fp12,fp2 /* and avoid setting "invalid operation". */ + li r0,0 + stfd fp11,-16(r1) + bgt- cr6,.L9 /* if > TWO63 return "invalid operation". */ + ble+ cr7,.L9 /* If < TWO52 only thy high double is used. */ + stfd fp12,-8(r1) + nop /* Insure the following load is in a different dispatch group */ + nop /* to avoid pipe stall on POWER4&5. */ + nop +.L8: + ld r0,-8(r1) +.L9: + ld r3,-16(r1) + add r3,r3,r0 + blr + +/* The high double is >= TWO63 so it looks like we are "out of range". + But this may be caused by rounding of the high double and the + negative low double may bring it back into range. So we need to + de-round the high double and invert the low double without changing + the effective long double value. To do this we compute a special + value (tau) that we can subtract from the high double and add to + the low double before conversion. The resulting integers can be + summed to get the total value. + + tau = floor(x_high/TWO52); + x0 = x_high - tau; + x1 = x_low + tau; */ +.L2: + fdiv fp8,fp1,fp13 /* x_high/TWO52 */ + fctidz fp0,fp8 + fcfid fp8,fp0 /* tau = floor(x_high/TWO52); */ + fsub fp3,fp1,fp8 /* x0 = x_high - tau; */ + fadd fp4,fp2,fp8 /* x1 = x_low + tau; */ + fctid fp11,fp3 + fctid fp12,fp4 + stfd fp11,-16(r1) + stfd fp12,-8(r1) + nop /* Insure the following load is in a different dispatch group */ + nop /* to avoid pipe stall on POWER4&5. */ + nop + ld r3,-16(r1) + ld r0,-8(r1) + addo. r3,r3,r0 + bnslr+ cr0 /* if the sum does not overflow, return. */ + fctid fp11,fp1 /* Otherwise we want to set "invalid operation". */ + li r0,0 + stfd fp11,-16(r1) + b .L9 + +END (__llrintl) + +strong_alias (__llrintl, __lrintl) +long_double_symbol (libm, __llrintl, llrintl) +long_double_symbol (libm, __lrintl, lrintl) diff --git a/sysdeps/powerpc/powerpc64/fpu/s_llround.S b/sysdeps/powerpc/powerpc64/fpu/s_llround.S index a3dcd4c..d023b8f 100644 --- a/sysdeps/powerpc/powerpc64/fpu/s_llround.S +++ b/sysdeps/powerpc/powerpc64/fpu/s_llround.S @@ -1,5 +1,5 @@ /* llround function. PowerPC64 version. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -18,6 +18,7 @@ 02111-1307 USA. */ #include +#include .section ".toc","aw" .LC0: /* -0.0 */ @@ -66,3 +67,7 @@ strong_alias (__llround, __llroundl) weak_alias (__lround, lroundl) strong_alias (__lround, __lroundl) #endif +#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1) +compat_symbol (libm, __llround, llroundl, GLIBC_2_1) +compat_symbol (libm, __lround, lroundl, GLIBC_2_1) +#endif diff --git a/sysdeps/powerpc/powerpc64/fpu/s_llroundf.S b/sysdeps/powerpc/powerpc64/fpu/s_llroundf.S index b5ca43b..bbbd054 100644 --- a/sysdeps/powerpc/powerpc64/fpu/s_llroundf.S +++ b/sysdeps/powerpc/powerpc64/fpu/s_llroundf.S @@ -1,5 +1,5 @@ /* llroundf function. PowerPC64 version. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -28,8 +28,8 @@ /* long long [r3] llroundf (float x [fp1]) IEEE 1003.1 llroundf function. IEEE specifies "roundf to the nearest - integer value, roundfing halfway cases away from zero, regardless of - the current roundfing mode." However PowerPC Architecture defines + integer value, rounding halfway cases away from zero, regardless of + the current rounding mode." However PowerPC Architecture defines "roundf to Nearest" as "Choose the best approximation. In case of a tie, choose the one that is even (least significant bit o).". So we can't use the PowerPC "round to Nearest" mode. Instead we set diff --git a/sysdeps/powerpc/powerpc64/fpu/s_llroundl.S b/sysdeps/powerpc/powerpc64/fpu/s_llroundl.S new file mode 100644 index 0000000..b7aeb39 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_llroundl.S @@ -0,0 +1,147 @@ +/* llroundl function. + IBM extended format long double version. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + + .section ".toc","aw" +.LC0: /* 0.0 */ + .tc FD_00000000_0[TC],0x0000000000000000 +.LC1: /* 0.5 */ + .tc FD_3fe00000_0[TC],0x3fe0000000000000 +.LC2: /* 2**52 */ + .tc FD_43300000_0[TC],0x4330000000000000 +.LC3: /* 2**63 */ + .tc FD_43E00000_0[TC],0x43e0000000000000 + .section ".text" + +/* long long [r3] llround (long double x [fp1,fp2]) + IEEE 1003.1 llroundl function. IEEE specifies "round to the nearest + integer value, rounding halfway cases away from zero, regardless of + the current rounding mode." However PowerPC Architecture defines + "round to Nearest" as "Choose the best approximation. In case of a + tie, choose the one that is even (least significant bit o).". + So we can't use the PowerPC "round to Nearest" mode. Instead we set + "round toward Zero" mode and round by adding +-0.5 before rounding + toward zero. The "Floating Convert To Integer Doubleword with round + toward zero" instruction handles the conversion including the + overflow cases and signalling "Invalid Operation". + + PowerPC64 long double uses the IBM extended format which is + represented two 64-floating point double values. The values are + non-overlapping giving an effective precision of 106 bits. The first + double contains the high order bits of mantisa and is always rounded + to represent a normal rounding of long double to double. Since the + long double value is sum of the high and low values, the low double + normally has the opposite sign to compensate for the this rounding. + + For long double there is 4 cases: + 1) |x| < 2**52, all the integer bits are in the high double. + Round and convert the high double to long long. + 2) 2**52 <= |x|< 2**63, Still fits but need bits from both doubles. + Round the low double, convert both, then sum the long long values. + 3) |x| == 2**63, Looks like an overflow but may not be due to rounding + of the high double. + See the description following lable L2. + 4) |x| > 2**63, This will overflow the 64-bit signed integer. + Treat like case #1. The fctidz instruction will generate the + appropriate and signal "invalid operation". + + */ + +ENTRY (__llroundl) + fabs fp0,fp1 + lfd fp13,.LC2@toc(2) /* 2**52 */ + lfd fp12,.LC3@toc(2) /* 2**63 */ + lfd fp11,.LC0@toc(2) /* 0.0 */ + lfd fp10,.LC1@toc(2) /* 0.5 */ + fcmpu cr0,fp0,fp12 /* if (x < TWO63 */ + fcmpu cr7,fp0,fp13 /* if (x < TWO52 */ + fcmpu cr6,fp1,fp11 /* if (x > 0.0) */ + bge- cr0,.L2 + bge- cr7,.L8 + ble- cr6,.L4 + fadd fp4,fp2,fp10 /* x+= 0.5; */ + fadd fp5,fp1,fp4 /* x+= 0.5; */ +.L9: + fctidz fp3,fp5 /* Convert To Integer DW llround toward 0. */ + stfd fp3,-16(r1) + nop /* Insure the following load is in a different dispatch group */ + nop /* to avoid pipe stall on POWER4&5. */ + nop + ld r3,-16(r1) + blr +.L4: + fsub fp4,fp2,fp10 /* x-= 0.5; */ + fadd fp5,fp1,fp4 /* x+= 0.5; */ + b .L9 +.L8: + ble cr6,.L6 + fneg fp10,fp10 +.L6: + fadd fp2,fp2,fp10 + fctidz fp3,fp1 /* Convert To Integer DW llround toward 0. */ + fctidz fp4,fp2 /* Convert To Integer DW llround toward 0. */ + stfd fp3,-16(r1) + stfd fp4,-8(r1) + nop /* Insure the following load is in a different dispatch group */ + nop /* to avoid pipe stall on POWER4&5. */ + nop + ld r3,-16(r1) + ld r0,-8(r1) + add r3,r3,r0 + blr +.L2: +/* The high double is >= TWO63 so it looks like we are "out of range". + But this may be caused by rounding of the high double and the + negative low double may bring it back into range. So we need to + de-round the high double and invert the low double without changing + the effective long double value. To do this we compute a special + value (tau) that we can subtract from the high double and add to + the low double before conversion. The resulting integers can be + summed to get the total value. + + tau = floor(x_high/TWO52); + x0 = x_high - tau; + x1 = x_low + tau; */ +.L2: + fdiv fp8,fp1,fp13 /* x_high/TWO52 */ + bgt- cr0,.L9 /* if x > TWO63 */ + fctidz fp0,fp8 + fcfid fp8,fp0 /* tau = floor(x_high/TWO52); */ + fsub fp3,fp1,fp8 /* x0 = x_high - tau; */ + fadd fp4,fp2,fp8 /* x1 = x_low + tau; */ + fctid fp11,fp3 + fctid fp12,fp4 + stfd fp11,-16(r1) + stfd fp12,-8(r1) + nop /* Insure the following load is in a different dispatch group */ + nop /* to avoid pipe stall on POWER4&5. */ + nop + ld r3,-16(r1) + ld r0,-8(r1) + addo. r3,r3,r0 + bnslr+ cr0 /* if the sum does not overflow, return. */ + b .L9 /* Otherwise we want to set "invalid operation". */ +END (__llroundl) + +strong_alias (__llroundl, __lroundl) +long_double_symbol (libm, __llroundl, llroundl) +long_double_symbol (libm, __lroundl, lroundl) diff --git a/sysdeps/powerpc/powerpc64/fpu/s_lrintl.S b/sysdeps/powerpc/powerpc64/fpu/s_lrintl.S new file mode 100644 index 0000000..6c82d2e --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_lrintl.S @@ -0,0 +1,2 @@ +/* __lrintl is in s_llrintl.c */ +/* __lrintl is in s_llrintl.c */ diff --git a/sysdeps/powerpc/powerpc64/fpu/s_lroundl.S b/sysdeps/powerpc/powerpc64/fpu/s_lroundl.S new file mode 100644 index 0000000..b24dfd8 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_lroundl.S @@ -0,0 +1,2 @@ +/* __lroundl is in s_llroundl.S */ +/* __lroundl is in s_llroundl.S */ diff --git a/sysdeps/powerpc/powerpc64/fpu/s_nearbyintl.S b/sysdeps/powerpc/powerpc64/fpu/s_nearbyintl.S new file mode 100644 index 0000000..0d0eb36 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_nearbyintl.S @@ -0,0 +1,114 @@ +/* nearbyint long double. + IBM extended format long double version. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + + .section ".toc","aw" +.LC0: /* 2**52 */ + .tc FD_43300000_0[TC],0x4330000000000000 + .section ".text" + +/* long double [fp1,fp2] nearbyintl (long double x [fp1,fp2]) + IEEE 1003.1 nearbyintl function. nearbyintl is simular to the rintl + but does raise the "inexact" exception. This implementation is + based on rintl but explicitly maskes the inexact exception on entry + and clears any pending inexact before restoring the exception mask + on exit. + + PowerPC64 long double uses the IBM extended format which is + represented two 64-floating point double values. The values are + non-overlapping giving an effective precision of 106 bits. The first + double contains the high order bits of mantisa and is always rounded + to represent a normal rounding of long double to double. Since the + long double value is sum of the high and low values, the low double + normally has the opposite sign to compensate for the this rounding. + + For long double there are two cases: + 1) |x| < 2**52, all the integer bits are in the high double. + floor the high double and set the low double to -0.0. + 2) |x| >= 2**52, Rounding involves both doubles. + See the comment before lable .L2 for details. + */ +ENTRY (__nearbyintl) + mffs fp11 /* Save current FPSCR. */ + lfd fp13,.LC0@toc(2) + fabs fp0,fp1 + mtfsb0 28 /* Disable "inexact" exceptions. */ + fsub fp12,fp13,fp13 /* generate 0.0 */ + fabs fp9,fp2 + fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO52) */ + fcmpu cr6,fp1,fp12 /* if (x > 0.0) */ + bnl- cr7,.L2 + fmr fp2,fp12 + bng- cr6,.L4 + fadd fp1,fp1,fp13 /* x+= TWO52; */ + fsub fp1,fp1,fp13 /* x-= TWO52; */ + b .L9 +.L4: + bnl- cr6,.L9 /* if (x < 0.0) */ + fsub fp1,fp13,fp1 /* x = TWO52 - x; */ + fsub fp0,fp1,fp13 /* x = - (x - TWO52); */ + fneg fp1,fp0 +.L9: + mtfsb0 6 /* Clear any pending "inexact" exceptions. */ + mtfsf 0x01,fp11 /* restore exception mask. */ + blr + +/* The high double is > TWO52 so we need to round the low double and + perhaps the high double. This gets a bit tricky so we use the + following algorithm: + + tau = floor(x_high/TWO52); + x0 = x_high - tau; + x1 = x_low + tau; + r1 = nearbyint(x1); + y_high = x0 + r1; + y_low = r1 - tau; + return y; */ +.L2: + fcmpu cr7,fp9,fp13 /* if (|x_low| > TWO52) */ + fcmpu cr0,fp9,fp12 /* || (|x_low| == 0.0) */ + bge- cr7,.L9 /* return x; */ + beq- cr0,.L9 + fdiv fp8,fp1,fp13 /* x_high/TWO52 */ + fctidz fp0,fp8 + fcfid fp8,fp0 /* tau = floor(x_high/TWO52); */ + fsub fp3,fp1,fp8 /* x0 = x_high - tau; */ + fadd fp4,fp2,fp8 /* x1 = x_low + tau; */ + + fcmpu cr6,fp4,fp12 /* if (x1 > 0.0) */ + bng- cr6,.L8 + fadd fp5,fp4,fp13 /* r1 = x1 + TWO52; */ + fsub fp5,fp5,fp13 /* r1 = r1 - TWO52; */ + b .L6 +.L8: + fmr fp5,fp4 + bge- cr6,.L6 /* if (x1 < 0.0) */ + fsub fp5,fp13,fp4 /* r1 = TWO52 - x1; */ + fsub fp0,fp5,fp13 /* r1 = - (r1 - TWO52); */ + fneg fp5,fp0 +.L6: + fadd fp1,fp3,fp5 /* y_high = x0 + r1; */ + fsub fp2,fp5,fp8 /* y_low = r1 - tau; */ + b .L9 +END (__nearbyintl) + +long_double_symbol (libm, __nearbyintl, nearbyintl) diff --git a/sysdeps/powerpc/powerpc64/fpu/s_rint.S b/sysdeps/powerpc/powerpc64/fpu/s_rint.S index 0c0e0ba..b4fbc0b 100644 --- a/sysdeps/powerpc/powerpc64/fpu/s_rint.S +++ b/sysdeps/powerpc/powerpc64/fpu/s_rint.S @@ -1,5 +1,5 @@ /* Round to int floating-point values. PowerPC64 version. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -21,6 +21,7 @@ when it's coded in C. */ #include +#include .section ".toc","aw" .LC0: /* 2**52 */ @@ -54,3 +55,6 @@ weak_alias (__rint, rint) weak_alias (__rint, rintl) strong_alias (__rint, __rintl) #endif +#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0) +compat_symbol (libm, __rint, rintl, GLIBC_2_0) +#endif diff --git a/sysdeps/powerpc/powerpc64/fpu/s_rintl.S b/sysdeps/powerpc/powerpc64/fpu/s_rintl.S new file mode 100644 index 0000000..2ca2d44 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_rintl.S @@ -0,0 +1,113 @@ +/* Round to int long double floating-point values. + IBM extended format long double version. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* This has been coded in assembler because GCC makes such a mess of it + when it's coded in C. */ + +#include +#include + + .section ".toc","aw" +.LC0: /* 2**52 */ + .tc FD_43300000_0[TC],0x4330000000000000 + .section ".text" + +ENTRY (__rintl) + lfd fp13,.LC0@toc(2) + fabs fp0,fp1 + fsub fp12,fp13,fp13 /* generate 0.0 */ + fabs fp9,fp2 + fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO52) */ + fcmpu cr6,fp1,fp12 /* if (x > 0.0) */ + bnl- cr7,.L2 + fmr fp2,fp12 + bng- cr6,.L1 + fadd fp1,fp1,fp13 /* x+= TWO52; */ + fsub fp1,fp1,fp13 /* x-= TWO52; */ + fabs fp1,fp1 /* if (x == 0.0) */ + blr /* x = 0.0; */ +.L1: + bnllr- cr6 /* if (x < 0.0) */ + fsub fp1,fp1,fp13 /* x-= TWO52; */ + fadd fp1,fp1,fp13 /* x+= TWO52; */ + fnabs fp1,fp1 /* if (x == 0.0) */ + blr /* x = -0.0; */ + +/* The high double is > TWO52 so we need to round the low double and + perhaps the high double. In this case we have to round the low + double and handle any adjustment to the high double that may be + caused by rounding (up). This is complicated by the fact that the + high double may already be rounded and the low double may have the + opposite sign to compensate.This gets a bit tricky so we use the + following algorithm: + + tau = floor(x_high/TWO52); + x0 = x_high - tau; + x1 = x_low + tau; + r1 = rint(x1); + y_high = x0 + r1; + y_low = x0 - y_high + r1; + return y; */ +.L2: + fcmpu cr7,fp9,fp13 /* if (|x_low| > TWO52) */ + fcmpu cr0,fp9,fp12 /* || (|x_low| == 0.0) */ + fcmpu cr5,fp2,fp12 /* if (x_low > 0.0) */ + bgelr- cr7 /* return x; */ + beqlr- cr0 + fdiv fp8,fp1,fp13 /* x_high/TWO52 */ + + bng- cr6,.L6 /* if (x > 0.0) */ + fctidz fp0,fp8 + fcfid fp8,fp0 /* tau = floor(x_high/TWO52); */ + fadd fp8,fp8,fp8 /* tau++; Make tau even */ + bng cr5,.L4 /* if (x_low > 0.0) */ + fmr fp3,fp1 + fmr fp4,fp2 + b .L5 +.L4: /* if (x_low < 0.0) */ + fsub fp3,fp1,fp8 /* x0 = x_high - tau; */ + fadd fp4,fp2,fp8 /* x1 = x_low + tau; */ +.L5: + fadd fp5,fp4,fp13 /* r1 = x1 + TWO52; */ + fsub fp5,fp5,fp13 /* r1 = r1 - TWO52; */ + b .L9 +.L6: /* if (x < 0.0) */ + fctidz fp0,fp8 + fcfid fp8,fp0 /* tau = floor(x_high/TWO52); */ + fadd fp8,fp8,fp8 /* tau++; Make tau even */ + bnl cr5,.L7 /* if (x_low < 0.0) */ + fmr fp3,fp1 + fmr fp4,fp2 + b .L8 +.L7: /* if (x_low > 0.0) */ + fsub fp3,fp1,fp8 /* x0 = x_high - tau; */ + fadd fp4,fp2,fp8 /* x1 = x_low + tau; */ +.L8: + fsub fp5,fp13,fp4 /* r1 = TWO52 - x1; */ + fsub fp0,fp5,fp13 /* r1 = - (r1 - TWO52); */ + fneg fp5,fp0 +.L9: + fadd fp1,fp3,fp5 /* y_high = x0 + r1; */ + fsub fp2,fp3,fp1 /* y_low = x0 - y_high + r1; */ + fadd fp2,fp2,fp5 + blr +END (__rintl) + +long_double_symbol (libm, __rintl, rintl) diff --git a/sysdeps/powerpc/powerpc64/fpu/s_round.S b/sysdeps/powerpc/powerpc64/fpu/s_round.S index b07a7ea..15afca1 100644 --- a/sysdeps/powerpc/powerpc64/fpu/s_round.S +++ b/sysdeps/powerpc/powerpc64/fpu/s_round.S @@ -1,5 +1,5 @@ /* round function. PowerPC64 version. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -18,6 +18,7 @@ 02111-1307 USA. */ #include +#include .section ".toc","aw" .LC0: /* 2**52 */ @@ -73,3 +74,6 @@ weak_alias (__round, round) weak_alias (__round, roundl) strong_alias (__round, __roundl) #endif +#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1) +compat_symbol (libm, __round, roundl, GLIBC_2_1) +#endif diff --git a/sysdeps/powerpc/powerpc64/fpu/s_roundl.S b/sysdeps/powerpc/powerpc64/fpu/s_roundl.S new file mode 100644 index 0000000..20da828 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_roundl.S @@ -0,0 +1,133 @@ +/* long double round function. + IBM extended format long double version. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + + .section ".toc","aw" +.LC0: /* 2**52 */ + .tc FD_43300000_0[TC],0x4330000000000000 +.LC1: /* 0.5 */ + .tc FD_3fe00000_0[TC],0x3fe0000000000000 + .section ".text" + +/* long double [fp1,fp2] roundl (long double x [fp1,fp2]) + IEEE 1003.1 round function. IEEE specifies "round to the nearest + integer value, rounding halfway cases away from zero, regardless of + the current rounding mode." However PowerPC Architecture defines + "Round to Nearest" as "Choose the best approximation. In case of a + tie, choose the one that is even (least significant bit o).". + So we can't use the PowerPC "Round to Nearest" mode. Instead we set + "Round toward Zero" mode and round by adding +-0.5 before rounding + to the integer value. */ + +ENTRY (__roundl) + mffs fp11 /* Save current FPU rounding mode. */ + lfd fp13,.LC0@toc(2) + fabs fp0,fp1 + fabs fp9,fp2 + fsub fp12,fp13,fp13 /* generate 0.0 */ + fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO52) */ + fcmpu cr6,fp1,fp12 /* if (x > 0.0) */ + bnl- cr7,.L2 + mtfsfi 7,1 /* Set rounding mode toward 0. */ + lfd fp10,.LC1@toc(2) + ble- cr6,.L1 + fneg fp2,fp12 + fadd fp1,fp1,fp10 /* x+= 0.5; */ + fadd fp1,fp1,fp13 /* x+= TWO52; */ + fsub fp1,fp1,fp13 /* x-= TWO52; */ + fabs fp1,fp1 /* if (x == 0.0) x = 0.0; */ +.L0: + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + blr +.L1: + fsub fp9,fp1,fp10 /* x-= 0.5; */ + fneg fp2,fp12 + bge- cr6,.L0 /* if (x < 0.0) */ + fsub fp1,fp9,fp13 /* x-= TWO52; */ + fadd fp1,fp1,fp13 /* x+= TWO52; */ + fnabs fp1,fp1 /* if (x == 0.0) x = -0.0; */ + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + blr + +/* The high double is > TWO52 so we need to round the low double and + perhaps the high double. In this case we have to round the low + double and handle any adjustment to the high double that may be + caused by rounding (up). This is complicated by the fact that the + high double may already be rounded and the low double may have the + opposite sign to compensate.This gets a bit tricky so we use the + following algorithm: + + tau = floor(x_high/TWO52); + x0 = x_high - tau; + x1 = x_low + tau; + r1 = rint(x1); + y_high = x0 + r1; + y_low = x0 - y_high + r1; + return y; */ +.L2: + fcmpu cr7,fp9,fp13 /* if (|x_low| > TWO52) */ + fcmpu cr0,fp9,fp12 /* || (|x_low| == 0.0) */ + fcmpu cr5,fp2,fp12 /* if (x_low > 0.0) */ + lfd fp10,.LC1@toc(2) + bgelr- cr7 /* return x; */ + beqlr- cr0 + mtfsfi 7,1 /* Set rounding mode toward 0. */ + fdiv fp8,fp1,fp13 /* x_high/TWO52 */ + + bng- cr6,.L6 /* if (x > 0.0) */ + fctidz fp0,fp8 + fcfid fp8,fp0 /* tau = floor(x_high/TWO52); */ + bng cr5,.L4 /* if (x_low > 0.0) */ + fmr fp3,fp1 + fmr fp4,fp2 + b .L5 +.L4: /* if (x_low < 0.0) */ + fsub fp3,fp1,fp8 /* x0 = x_high - tau; */ + fadd fp4,fp2,fp8 /* x1 = x_low + tau; */ +.L5: + fadd fp5,fp4,fp10 /* r1 = x1 + 0.5; */ + fadd fp5,fp5,fp13 /* r1 = r1 + TWO52; */ + fsub fp5,fp5,fp13 /* r1 = r1 - TWO52; */ + b .L9 +.L6: /* if (x < 0.0) */ + fctidz fp0,fp8 + fcfid fp8,fp0 /* tau = floor(x_high/TWO52); */ + bnl cr5,.L7 /* if (x_low < 0.0) */ + fmr fp3,fp1 + fmr fp4,fp2 + b .L8 +.L7: /* if (x_low > 0.0) */ + fsub fp3,fp1,fp8 /* x0 = x_high - tau; */ + fadd fp4,fp2,fp8 /* x1 = x_low + tau; */ +.L8: + fsub fp5,fp4,fp10 /* r1 = x1 - 0.5; */ + fsub fp5,fp5,fp13 /* r1-= TWO52; */ + fadd fp5,fp5,fp13 /* r1+= TWO52; */ +.L9: + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + fadd fp1,fp3,fp5 /* y_high = x0 + r1; */ + fsub fp2,fp3,fp1 /* y_low = x0 - y_high + r1; */ + fadd fp2,fp2,fp5 + blr +END (__roundl) + +long_double_symbol (libm, __roundl, roundl) diff --git a/sysdeps/powerpc/powerpc64/fpu/s_trunc.S b/sysdeps/powerpc/powerpc64/fpu/s_trunc.S index d69e371..086ed00 100644 --- a/sysdeps/powerpc/powerpc64/fpu/s_trunc.S +++ b/sysdeps/powerpc/powerpc64/fpu/s_trunc.S @@ -1,5 +1,5 @@ /* trunc function. PowerPC64 version. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -18,6 +18,7 @@ 02111-1307 USA. */ #include +#include .section ".toc","aw" .LC0: /* 2**52 */ @@ -46,7 +47,7 @@ EALIGN (__trunc, 4, 0) fsub fp1,fp1,fp13 /* x-= TWO52; */ fabs fp1,fp1 /* if (x == 0.0) */ /* x = 0.0; */ - mtfsf 0x01,fp11 /* restore previous truncing mode. */ + mtfsf 0x01,fp11 /* restore previous rounding mode. */ blr .L4: bge- cr6,.L9 /* if (x < 0.0) */ @@ -65,3 +66,6 @@ weak_alias (__trunc, trunc) weak_alias (__trunc, truncl) strong_alias (__trunc, __truncl) #endif +#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1) +compat_symbol (libm, __trunc, truncl, GLIBC_2_1) +#endif diff --git a/sysdeps/powerpc/powerpc64/fpu/s_truncf.S b/sysdeps/powerpc/powerpc64/fpu/s_truncf.S index 15f53da..1456e7f 100644 --- a/sysdeps/powerpc/powerpc64/fpu/s_truncf.S +++ b/sysdeps/powerpc/powerpc64/fpu/s_truncf.S @@ -1,5 +1,5 @@ /* truncf function. PowerPC64 version. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -46,7 +46,7 @@ EALIGN (__truncf, 4, 0) fsubs fp1,fp1,fp13 /* x-= TWO23; */ fabs fp1,fp1 /* if (x == 0.0) */ /* x = 0.0; */ - mtfsf 0x01,fp11 /* restore previous truncing mode. */ + mtfsf 0x01,fp11 /* restore previous rounding mode. */ blr .L4: bge- cr6,.L9 /* if (x < 0.0) */ diff --git a/sysdeps/powerpc/powerpc64/fpu/s_truncl.S b/sysdeps/powerpc/powerpc64/fpu/s_truncl.S new file mode 100644 index 0000000..1864fc1 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/fpu/s_truncl.S @@ -0,0 +1,121 @@ +/* long double trunc function. + IBM extended format long double version. + Copyright (C) 2004, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + + .section ".toc","aw" +.LC0: /* 2**52 */ + .tc FD_43300000_0[TC],0x4330000000000000 +.LC1: /* 0.5 */ + .tc FD_3fe00000_0[TC],0x3fe0000000000000 + .section ".text" + +/* long double [fp1,fp2] truncl (long double x [fp1,fp2]) */ + +ENTRY (__truncl) + mffs fp11 /* Save current FPU rounding mode. */ + lfd fp13,.LC0@toc(2) + fabs fp0,fp1 + fabs fp9,fp2 + fsub fp12,fp13,fp13 /* generate 0.0 */ + fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO52) */ + fcmpu cr6,fp1,fp12 /* if (x > 0.0) */ + bnl- cr7,.L2 + mtfsfi 7,1 /* Set rounding mode toward 0. */ + ble- cr6,.L1 + fneg fp2,fp12 + fadd fp1,fp1,fp13 /* x+= TWO52; */ + fsub fp1,fp1,fp13 /* x-= TWO52; */ + fabs fp1,fp1 /* if (x == 0.0) x = 0.0; */ +.L0: + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + blr +.L1: + fneg fp2,fp12 + bge- cr6,.L0 /* if (x < 0.0) */ + fsub fp1,fp1,fp13 /* x-= TWO52; */ + fadd fp1,fp1,fp13 /* x+= TWO52; */ + fnabs fp1,fp1 /* if (x == 0.0) x = -0.0; */ + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + blr + +/* The high double is > TWO52 so we need to round the low double and + perhaps the high double. In this case we have to round the low + double and handle any adjustment to the high double that may be + caused by rounding (up). This is complicated by the fact that the + high double may already be rounded and the low double may have the + opposite sign to compensate.This gets a bit tricky so we use the + following algorithm: + + tau = floor(x_high/TWO52); + x0 = x_high - tau; + x1 = x_low + tau; + r1 = rint(x1); + y_high = x0 + r1; + y_low = x0 - y_high + r1; + return y; */ +.L2: + fcmpu cr7,fp9,fp13 /* if (|x_low| > TWO52) */ + fcmpu cr0,fp9,fp12 /* || (|x_low| == 0.0) */ + fcmpu cr5,fp2,fp12 /* if (x_low > 0.0) */ + bgelr- cr7 /* return x; */ + beqlr- cr0 + mtfsfi 7,1 /* Set rounding mode toward 0. */ + fdiv fp8,fp1,fp13 /* x_high/TWO52 */ + + bng- cr6,.L6 /* if (x > 0.0) */ + fctidz fp0,fp8 + fcfid fp8,fp0 /* tau = floor(x_high/TWO52); */ + fadd fp8,fp8,fp8 /* tau++; Make tau even */ + bng cr5,.L4 /* if (x_low > 0.0) */ + fmr fp3,fp1 + fmr fp4,fp2 + b .L5 +.L4: /* if (x_low < 0.0) */ + fsub fp3,fp1,fp8 /* x0 = x_high - tau; */ + fadd fp4,fp2,fp8 /* x1 = x_low + tau; */ +.L5: + fadd fp5,fp4,fp13 /* r1 = r1 + TWO52; */ + fsub fp5,fp5,fp13 /* r1 = r1 - TWO52; */ + b .L9 +.L6: /* if (x < 0.0) */ + fctidz fp0,fp8 + fcfid fp8,fp0 /* tau = floor(x_high/TWO52); */ + fadd fp8,fp8,fp8 /* tau++; Make tau even */ + bnl cr5,.L7 /* if (x_low < 0.0) */ + fmr fp3,fp1 + fmr fp4,fp2 + b .L8 +.L7: /* if (x_low > 0.0) */ + fsub fp3,fp1,fp8 /* x0 = x_high - tau; */ + fadd fp4,fp2,fp8 /* x1 = x_low + tau; */ +.L8: + fsub fp5,fp4,fp13 /* r1-= TWO52; */ + fadd fp5,fp5,fp13 /* r1+= TWO52; */ +.L9: + mtfsf 0x01,fp11 /* restore previous rounding mode. */ + fadd fp1,fp3,fp5 /* y_high = x0 + r1; */ + fsub fp2,fp3,fp1 /* y_low = x0 - y_high + r1; */ + fadd fp2,fp2,fp5 + blr +END (__truncl) + +long_double_symbol (libm, __truncl, truncl) diff --git a/sysdeps/unix/sysv/linux/powerpc/Implies b/sysdeps/unix/sysv/linux/powerpc/Implies new file mode 100644 index 0000000..ff27cdb --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/Implies @@ -0,0 +1,4 @@ +# Make sure these routines come before ldbl-opt. +ieee754/ldbl-128ibm +# These supply the ABI compatibility for when long double was double. +ieee754/ldbl-opt diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/wordsize.h b/sysdeps/unix/sysv/linux/powerpc/bits/wordsize.h new file mode 100644 index 0000000..cf93423 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/bits/wordsize.h @@ -0,0 +1,19 @@ +/* Determine the wordsize from the preprocessor defines. */ + +#if defined __powerpc64__ +# define __WORDSIZE 64 +# define __WORDSIZE_COMPAT32 1 +#else +# define __WORDSIZE 32 +#endif + +#if !defined __NO_LONG_DOUBLE_MATH && !defined __LONG_DOUBLE_MATH_OPTIONAL + +/* Signal the glibc ABI didn't used to have a `long double'. + The changes all the `long double' function variants to be redirects + to the double functions. */ +# define __LONG_DOUBLE_MATH_OPTIONAL 1 +# ifndef __LONG_DOUBLE_128__ +# define __NO_LONG_DOUBLE_MATH 1 +# endif +#endif diff --git a/sysdeps/unix/sysv/linux/powerpc/configure b/sysdeps/unix/sysv/linux/powerpc/configure new file mode 100644 index 0000000..070bf5c --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/configure @@ -0,0 +1,135 @@ +# This file is generated from configure.in by Autoconf. DO NOT EDIT! + # Local configure fragment for sysdeps/unix/sysv/linux/powerpc/. + + +echo "$as_me:$LINENO: checking whether $CC $CFLAGS -mlong-double-128 uses IBM extended format" >&5 +echo $ECHO_N "checking whether $CC $CFLAGS -mlong-double-128 uses IBM extended format... $ECHO_C" >&6 +if test "${libc_cv_mlong_double_128ibm+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -mlong-double-128" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ + +#if LDBL_MANT_DIG != 106 +# error "compiler doesn't implement IBM extended format of long double" +#endif +long double foobar (long double x) { return x; } + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + libc_cv_mlong_double_128ibm=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +libc_cv_mlong_double_128ibm=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS="$save_CFLAGS" +fi +echo "$as_me:$LINENO: result: $libc_cv_mlong_double_128ibm" >&5 +echo "${ECHO_T}$libc_cv_mlong_double_128ibm" >&6 + +if test "$libc_cv_mlong_double_128ibm" = no; then + echo "$as_me:$LINENO: checking whether $CC $CFLAGS supports -mabi=ibmlongdouble" >&5 +echo $ECHO_N "checking whether $CC $CFLAGS supports -mabi=ibmlongdouble... $ECHO_C" >&6 +if test "${libc_cv_mabi_ibmlongdouble+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -mlong-double-128 -mabi=ibmlongdouble" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ + +#if LDBL_MANT_DIG != 106 +# error "compiler doesn't implement IBM extended format of long double" +#endif +long double foobar (long double x) { return x; } + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + libc_cv_mabi_ibmlongdouble=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +libc_cv_mabi_ibmlongdouble=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS="$save_CFLAGS" +fi +echo "$as_me:$LINENO: result: $libc_cv_mabi_ibmlongdouble" >&5 +echo "${ECHO_T}$libc_cv_mabi_ibmlongdouble" >&6 + + if test "$libc_cv_mabi_ibmlongdouble" = yes; then + CFLAGS="$CFLAGS -mabi=ibmlongdouble" + else + { { echo "$as_me:$LINENO: error: this configuration requires -mlong-double-128 IBM extended format support" >&5 +echo "$as_me: error: this configuration requires -mlong-double-128 IBM extended format support" >&2;} + { (exit 1); exit 1; }; } + fi +fi diff --git a/sysdeps/unix/sysv/linux/powerpc/configure.in b/sysdeps/unix/sysv/linux/powerpc/configure.in new file mode 100644 index 0000000..1768ab1 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/configure.in @@ -0,0 +1,37 @@ +sinclude(./aclocal.m4)dnl Autoconf lossage +GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory. +# Local configure fragment for sysdeps/unix/sysv/linux/powerpc/. + +AC_CACHE_CHECK(whether $CC $CFLAGS -mlong-double-128 uses IBM extended format, + libc_cv_mlong_double_128ibm, [dnl +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -mlong-double-128" +AC_TRY_COMPILE([#include ], [ +#if LDBL_MANT_DIG != 106 +# error "compiler doesn't implement IBM extended format of long double" +#endif +long double foobar (long double x) { return x; }], + libc_cv_mlong_double_128ibm=yes, + libc_cv_mlong_double_128ibm=no) +CFLAGS="$save_CFLAGS"]) + +if test "$libc_cv_mlong_double_128ibm" = no; then + AC_CACHE_CHECK(whether $CC $CFLAGS supports -mabi=ibmlongdouble, + libc_cv_mabi_ibmlongdouble, [dnl + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -mlong-double-128 -mabi=ibmlongdouble" + AC_TRY_COMPILE([#include ], [ +#if LDBL_MANT_DIG != 106 +# error "compiler doesn't implement IBM extended format of long double" +#endif +long double foobar (long double x) { return x; }], + libc_cv_mabi_ibmlongdouble=yes, + libc_cv_mabi_ibmlongdouble=no) + CFLAGS="$save_CFLAGS"]) + + if test "$libc_cv_mabi_ibmlongdouble" = yes; then + CFLAGS="$CFLAGS -mabi=ibmlongdouble" + else + AC_MSG_ERROR([this configuration requires -mlong-double-128 IBM extended format support]) + fi +fi diff --git a/sysdeps/unix/sysv/linux/powerpc/nldbl-abi.h b/sysdeps/unix/sysv/linux/powerpc/nldbl-abi.h new file mode 100644 index 0000000..bd985cc --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/nldbl-abi.h @@ -0,0 +1,8 @@ +/* ABI version for long double switch. + This is used by the Versions and math_ldbl_opt.h files in + sysdeps/ieee754/ldbl-opt/. It gives the ABI version where + long double == double was replaced with proper long double + for libm *l functions and libc functions using long double. */ + +#define NLDBL_VERSION GLIBC_2.4 +#define LONG_DOUBLE_COMPAT_VERSION GLIBC_2_4 diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/Implies b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/Implies new file mode 100644 index 0000000..9f70f79 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/Implies @@ -0,0 +1,2 @@ +# Override ldbl-opt with powerpc32 specific routines. +powerpc/powerpc32/fpu diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fpu/Implies b/sysdeps/unix/sysv/linux/powerpc/powerpc64/fpu/Implies new file mode 100644 index 0000000..6243d2e --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/fpu/Implies @@ -0,0 +1,2 @@ +# Override ldbl-opt with powerpc64 specific routines. +powerpc/powerpc64/fpu -- cgit v1.1