aboutsummaryrefslogtreecommitdiff
path: root/math
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1997-06-19 19:11:22 +0000
committerUlrich Drepper <drepper@redhat.com>1997-06-19 19:11:22 +0000
commitd705269e75ff9846000abea981774b381b076482 (patch)
tree7bd717a8489ad113cb0d10b7628a88d6a55cb836 /math
parente7f1f046f51d95d5d05ada3abd3f2e88219118e9 (diff)
downloadglibc-d705269e75ff9846000abea981774b381b076482.zip
glibc-d705269e75ff9846000abea981774b381b076482.tar.gz
glibc-d705269e75ff9846000abea981774b381b076482.tar.bz2
1997-06-19 19:38 Ulrich Drepper <drepper@cygnus.com> * features.h: Define __STDC_IEC_559__ and _STDC_IEC_559_COMPLEX__. * elf/dl-minimal.c (__dcgettext): Remove assertion. * inet/rcmd.c: Correct a few typos. Reported by Eric Troan. * manual/Makefile (distribute): Add dir. * manual/dir: New file. * math/Makefile (libm-support): Rename s_rinttol, s_rinttoll, s_roundtol, and s_roundtoll to s_lrint, s_llrint, s_lround, and s_llround respectively. (libm-calls): Add e_gamma_r. * math/libm-test.c (check_int_exc): New function. (signbit_test): Remove test for sign of NaN. (gamma_test): Clear exception after test of existence. Correct tests and and epsilons. (lgamma_test): Likewise. (ilogb_test): Correct all tests. (scalb_test): Rewrite. (rinttol_test): Rename to lrint_test and correct tests. (rinttoll_test): Likewise. (roundtol_test): Likewise. (roundtoll_test): Likewise. (main): Call lrint/lround functions instead of rinttol/roundtol. * math/math.h: Change prototypes for rinttol/roundtol. * math/mathcalls.h: Rearrange prototypes according to ISO C9X draft. * sysdeps/generic/mathbits.h: Define FP_ILOGB0 and FP_ILOGBNAN. * sysdeps/i386/mathbits.h: Likewise. * sysdeps/libm-i387/e_scalb.S: Handle special cases correctly. * sysdeps/libm-i387/e_scalbf.S: Likewise. * sysdeps/libm-i387/e_scalbl.S: Likewise. * sysdeps/libm-i387/s_asinh.S: Handle -inf correctly. * sysdeps/libm-i387/s_asinhf.S: Likewise. * sysdeps/libm-i387/s_asinhl.S: Likewise. * sysdeps/libm-i387/s_ilogb.S: Optimize. * sysdeps/libm-i387/s_ilogbf.S: Likewise. * sysdeps/libm-i387/s_ilogbl.S: Likewise. * sysdeps/libm-i387/s_rinttol.S: Rename to... * sysdeps/libm-i387/s_lrint.S: ...this. * sysdeps/libm-i387/s_rinttoll.S: Rename to... * sysdeps/libm-i387/s_llrint.S: ...this. * sysdeps/libm-i387/s_remquo.S: Correctly set sign of remainder. * sysdeps/libm-i387/s_remquof.S: Likewise. * sysdeps/libm-i387/s_remquol.S: Likewise. * sysdeps/libm-i387/e_gamma_r.c: New file. Implementation of gamma function according to ISO C. * sysdeps/libm-i387/e_gammaf_r.c: New file. * sysdeps/libm-i387/e_gammal_r.c: New file. * sysdeps/libm-i387/e_lgamma_r.c: Don't let optimize compile the generation of exceptions away. * sysdeps/libm-i387/e_lgammaf_r.c: Likewise. * sysdeps/libm-i387/k_standard.c: Correct return value for infinity points of gamma function when not SVID mode. * sysdeps/libm-i387/s_rinttoll.c: Renamed to... * sysdeps/libm-i387/s_llrint.c: ...this. * sysdeps/libm-i387/s_rinttol.c: Renamed to... * sysdeps/libm-i387/s_lrint.c: ...this. * sysdeps/libm-i387/s_roundtoll.c: Renamed to... * sysdeps/libm-i387/s_llround.c: ...this. * sysdeps/libm-i387/s_roundtol.c: Renamed to... * sysdeps/libm-i387/s_lround.c: ..this. * sysdeps/libm-i387/s_scalbn.c: Change second parameter according to ISO C. * sysdeps/libm-i387/s_scalbnf.c: Likewise. * sysdeps/libm-i387/s_scalbnl.c: Likewise. * sysdeps/libm-i387/w_gamma.c: Call __ieee754_gamma_r if library mode is not _SVID_. * sysdeps/libm-i387/w_gammaf.c: Likewise. * sysdeps/libm-i387/w_gammal.c: Likewise. * sysdeps/m68k/fpu/__math.h: Rename __rinttol to __lrint and rinttol to lrint. * sysdeps/m68k/fpu/s_rinttol.c: Renamed to... * sysdeps/m68k/fpu/s_lrint.c: ...this. * sysdeps/m68k/fpu/s_rinttoll.c: Renamed to... * sysdeps/m68k/fpu/s_llrint.c: ...this. * md5-crypt/Makefile: Link md5test program with md5.o. * stdio-common/temptest.c: Don't use __stdio_gen_tempname which is not exported by the libc.so. * stdio-common/vfscanf.c: Correct scanning of strings after last change. * sysdeps/unix/sysv/linux/i386/sysdep.S: Use .comm to define errno. 1997-06-19 07:37 H.J. Lu <hjl@gnu.ai.mit.edu> * time/tzfile.c (__tzfile_read): Store getc () return in int. 1997-06-13 Miles Bader <miles@gnu.ai.mit.edu> * argp/argp-parse.c (argp_version_parser): Include `(PROGRAM ERROR)' in the no-version error text to indicate that something's fucked. [!_] (N_): New macro. (argp_default_options, argp_version_options): Wrap doc strings in N_(). 1997-06-12 Miles Bader <miles@gnu.ai.mit.edu> * argp/argp-parse.c (parser_parse_opt): Detect and report unhandled options here. (parser_parse_arg): Handle ARGP_KEY_ARGS here. Adjust NEXT pointer back if we fail to parse anything. (parser_parse_next): Simplify arg code. Leave state NEXT frobbing to parser_parse_arg. 1997-06-11 Miles Bader <miles@gnu.ai.mit.edu> * argp/argp.h (ARGP_KEY_ARGS, ARGP_KEY_FINI): New macros. * argp/argp-parse.c (parser_finalize): Do another pass over the parsers with ARGP_KEY_FINI. 1997-06-18 Miles Bader <miles@gnu.ai.mit.edu> * string/Makefile (routines): Add argz-replace. 1997-06-16 00:16 Miles Bader <miles@gnu.ai.mit.edu> * manual/string.texi (Argz Functions): Document argz_replace. 1997-06-12 Miles Bader <miles@gnu.ai.mit.edu> * string/argz.h (__argz_replace, argz_replace): New declarations. * string/argz-replace.c: New file. 1997-06-11 Miles Bader <miles@gnu.ai.mit.edu> * manual/argp.texi (Argp Special Keys): Document ARGP_KEY_ARGS. 1997-06-16 23:08 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * Makeconfig (libc-map): Remove definition. * Makerules (libc-map): Define it here, using the full name. (load-map-file): Remove case for empty $(..). ($(common-objpfx)libc.so): Revert last change. 1997-06-17 22:18 Mark Kettenis <kettenis@phys.uva.nl> * login/programs/utmpd.c (main): Improve signal handling. * login/programs/request.c (do_setutent, do_updwtmp): Allow arbitrary length filenames. * login/programs/utmpd.h (setutent_request, updwtmp_request): Get rid of fixed length file field. * login/utmp_daemon.c (do_setutent, do_updwtmp): Allow arbitrary length filenames. * login/programs/request.c (do_pututline): Don't fail if connection->position is -1 on entry. 1997-06-15 16:32 Mark Kettenis <kettenis@phys.uva.nl> * login/utmp_file.c (updwtmp_file): Use the same method for appending an entry as in pututline_file. 1997-06-11 18:59 Mark Kettenis <kettenis@phys.uva.nl> * login/utmp_file.c (getutent_r_file): Use read lock instead of write lock. (getutline_r_file, internal_getut_r): Lock utmp file. (updwtmp_file): Use fcntl to lock file instead of flock. 1997-06-18 00:11 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * stdio-common/vfscanf.c (inchar, ungetc): Don't count EOF as character read in/put back. * stdio-common/tstscanf.c: Add test case for this. 1997-06-17 22:17 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * libc.map: Add more symbols. 1997-06-18 12:01 Ulrich Drepper <drepper@cygnus.com> * manual/Makefile (install): Make sure `dir' file exists if we use install-info. 1997-06-17 19:32 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * manual/Makefile (info): Depend on dir-add.info. 1997-06-17 17:19 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * elf/ldd.bash.in: Fix spacing in message. 1997-06-17 14:28 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * elf/do-rel.h (elf_dynamic_do_rel): Always use version information if available. 1997-06-17 11:34 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sunrpc/Makefile ($(rpcsvc:%.x=$(objpfx)rpcsvc/%.h)): Make command non-empty to force make to recheck modification time. ($(rpcsvc:%.x=$(objpfx)x%.c)): Likewise. 1997-06-17 00:26 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/stub/e_acoshl.c: Set errno to ENOSYS. * sysdeps/stub/e_acosl.c: Likewise. * sysdeps/stub/e_asinl.c: Likewise. * sysdeps/stub/e_atan2l.c: Likewise. * sysdeps/stub/e_expl.c: Likewise. * sysdeps/stub/e_fmodl.c: Likewise. * sysdeps/stub/e_j0l.c: Likewise. * sysdeps/stub/e_j1l.c: Likewise. * sysdeps/stub/e_jnl.c: Likewise. * sysdeps/stub/e_lgammal_r.c: Likewise. * sysdeps/stub/e_log10l.c: Likewise. * sysdeps/stub/e_logl.c: Likewise. * sysdeps/stub/e_powl.c: Likewise. * sysdeps/stub/e_rem_pio2l.c: Likewise. * sysdeps/stub/e_sqrtl.c: Likewise. * sysdeps/stub/k_cosl.c: Likewise. * sysdeps/stub/k_rem_pio2l.c: Likewise. * sysdeps/stub/k_sinl.c: Likewise. * sysdeps/stub/k_tanl.c: Likewise. * sysdeps/stub/s_atanl.c: Likewise. * sysdeps/stub/s_erfl.c: Likewise. * sysdeps/stub/s_exp2.c: Likewise. * sysdeps/stub/s_exp2f.c: Likewise. * sysdeps/stub/s_exp2l.c: Likewise. * sysdeps/stub/s_expm1l.c: Likewise. * sysdeps/stub/s_log1pl.c: Likewise. * sysdeps/stub/s_log2l.c: Likewise. 1997-06-18 11:46 Ulrich Drepper <drepper@cygnus.com> * sysdeps/libm-ieee754/w_gamma.c: If _LIB_VERSION is _SVID_ compute result as before last change. * sysdeps/libm-ieee754/w_gammaf.c: Likewise. * sysdeps/libm-ieee754/w_gammal.c: Likewise. 1997-06-16 23:37 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/libm-ieee754/s_remquo.c: Fix off-by-one when computing quotient. * sysdeps/libm-ieee754/s_remquof.c: Likewise. * sysdeps/libm-ieee754/s_remquol.c: Likewise. * sysdeps/m68k/fpu/s_remquo.c: Remove FIXME and special case for quotient. * sysdeps/libm-ieee754/w_gamma.c: Add missing call to exp function. Don't use global signgam. * sysdeps/libm-ieee754/w_gammaf.c: Likewise. * sysdeps/libm-ieee754/w_gammal.c: Likewise. * math/Makefile (libm-calls): Remove w_gamma_r. * sysdeps/libm-ieee754/w_gamma_r.c: Remove file. * sysdeps/libm-ieee754/w_gammaf_r.c: Remove file. * sysdeps/libm-ieee754/w_gammal_r.c: Remove file. * math/libm-test.c (atanh_test): Declare x only if needed. (signbit_test): Fix typo. (gamma_test): Check whether function is implemented. Add epsilons. (lgamma_test): Likewise. (fmod_test): Add epsilons. (exp2_test): Use right function for existence test. 1997-06-07 09:20 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/powerpc/Dist: Add fenv_const.c. * sysdeps/unix/sysv/linux/Dist: Add net/if_slip.h. * sysdeps/unix/sysv/linux/powerpc/Dist: Add init-first.h and syscall.h. * sysdeps/unix/sysv/linux/sparc/Dist: Add init-first.h. * string/Makefile (distribute): Add tst-svc.expect. * nis/Makefile (distribute): Add nis_intern.h and Banner. * elf/Makefile (distribute): Add dl-hash.h. * Rules (subdir_echo-distinfo): Add headers from $(distribute). * login/Makefile (others): Add utmpdump. * sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Add net/if_slip.h. * manual/Makefile (dir-add.texi): Also look in indirectly included files. 1997-06-16 23:15 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/unix/sysv/linux/configure.in: Remove commands to generate stdio_lim.h. * sysdeps/unix/sysv/linux/mk-stdiolim.c: Remove. * sysdeps/unix/sysv/linux/Makefile: Add rules to generate stdio_lim.h here. (common-generated): Add generated files. (inhibit-stdio_lim): Define. * sysdeps/posix/Makefile [$(inhibit-stdio_lim)=yes]: Disable rules to generate stdio_lim.h. * sysdeps/unix/sysv/linux/Makefile: Suppress inclusion of dependecy files if no_deps is set. ($(objpfx)syscall-%.d): Add header file as target to dependency generation. 1997-06-14 19:19 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/unix/sysv/linux/arm/Dist: New file. 1997-06-14 17:59 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * extra-lib.mk (others): Depend on versioned shared library, not the unversioned one. * Makerules (build-shlib): Don't make the version link here. ($(common-objpfx)libc.so$(libc.so-version)): New rule for libc version link. 1997-06-16 03:07 Ulrich Drepper <drepper@cygnus.com> * sysdeps/libm-ieee754/k_standard.c: Undo change of Tue Aug 6 01:13:56 1996. * argp/argp-help.c (argp_args_usage): Supply correct argp to filter_doc. * argp/argp-help.c (hol_add_cluster): Initialize CL->depth. * argp/argp-help.c (_help): Supply STATE to argp_args_usage. * argp/argp.h (ARGP_KEY_HELP_ARGS_DOC): New macro. * argp/argp-fmtstream.c: Add casts to prevent warnings. * argp/argp.h (OPTION_NO_USAGE): New macro. * argp/argp-help.c (usage_long_opt, usage_argful_short_opt, * argp/argp-fmtstream.c (__argp_fmtstream_update): Account for case * argp/argp-help.c <stddef.h>: New include. * argp/argp.h (argp_state_help, __argp_state_help, argp_usage, * argp/argp.h (argp_program_bug_address): Make const. * argp/argp-parse.c (argp_default_parser): Set STATE->name for OPT_PROGNAME. * argp/argp-help.c (__argp_error, __argp_failure, __argp_state_help): * argp/argp-parse.c (parser_init): Set PARSER->state.flags.
Diffstat (limited to 'math')
-rw-r--r--math/Makefile8
-rw-r--r--math/libm-test.c287
-rw-r--r--math/math.h8
-rw-r--r--math/mathcalls.h19
4 files changed, 202 insertions, 120 deletions
diff --git a/math/Makefile b/math/Makefile
index fbbcad6..bd4506b 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -39,20 +39,20 @@ extra-libs-others = $(extra-libs)
libm-map := libm.map
libm-support = k_standard s_lib_version s_matherr s_signgam \
- s_rinttol s_rinttoll s_roundtol s_roundtoll \
+ s_lrint s_llrint s_lround s_llround \
fclrexcpt fgetexcptflg fraiseexcpt fsetexcptflg \
ftestexcept fegetround fesetround fegetenv feholdexcpt \
fesetenv feupdateenv
libm-calls = e_acos e_acosh e_asin e_atan2 e_atanh e_cosh e_exp e_fmod \
e_hypot e_j0 e_j1 e_jn e_lgamma_r e_log e_log10 e_pow \
- e_rem_pio2 e_remainder e_scalb e_sinh e_sqrt k_cos \
- k_rem_pio2 k_sin k_tan s_asinh s_atan s_cbrt \
+ e_rem_pio2 e_remainder e_scalb e_sinh e_sqrt e_gamma_r \
+ k_cos k_rem_pio2 k_sin k_tan s_asinh s_atan s_cbrt \
s_ceil s_copysign s_cos s_erf s_expm1 s_fabs s_finite \
s_floor s_frexp s_ilogb s_ldexp s_log1p s_logb \
s_modf s_nextafter s_rint s_scalbn s_significand \
s_sin s_tan s_tanh w_acos w_acosh w_asin \
w_atan2 w_atanh w_cosh w_drem w_exp w_fmod w_gamma \
- w_gamma_r w_hypot w_j0 w_j1 w_jn w_lgamma w_lgamma_r \
+ w_hypot w_j0 w_j1 w_jn w_lgamma w_lgamma_r \
w_log w_log10 w_pow w_remainder w_scalb w_sinh w_sqrt \
s_signbit s_fpclassify s_fmax s_fmin s_fdim s_nan s_trunc \
s_remquo s_log2 s_exp2 s_round s_nearbyint s_sincos \
diff --git a/math/libm-test.c b/math/libm-test.c
index be75383..5bf968f 100644
--- a/math/libm-test.c
+++ b/math/libm-test.c
@@ -47,8 +47,8 @@
ilogb, isfinite, isinf, isnan, isnormal,
ldexp, lgamma, log, log10, log1p, log2, logb,
modf, nearbyint, nextafter,
- pow, remainder, remquo, rint, rinttol, rinttoll,
- round, roundtol, roundtoll,
+ pow, remainder, remquo, rint, lrint, llrint,
+ round, lround, llround,
scalb, scalbn, signbit, sin, sincos, sinh, sqrt, tan, tanh, trunc
and for the following complex math functions:
@@ -593,6 +593,35 @@ check_int (const char *test_name, int computed, int expected)
fpstack_test (test_name);
}
+static void
+check_int_exc (const char *test_name, int computed, int expected,
+ short exception)
+{
+ int diff = computed - expected;
+ int result = diff == 0;
+
+ output_new_test (test_name);
+ test_exceptions (test_name, exception);
+
+ if (result)
+ {
+ output_pass_value ();
+ }
+ else
+ {
+ output_fail_value (test_name);
+ if (verbose > 1)
+ {
+ printf ("Result:\n");
+ printf (" is: %d\n", computed);
+ printf (" should be: %d\n", expected);
+ }
+ noErrors++;
+ }
+
+ fpstack_test (test_name);
+}
+
/*
check that computed and expected values are equal (long int values)
@@ -953,7 +982,9 @@ atan2_test (void)
static void
atanh_test (void)
{
+#ifndef TEST_INLINE
MATHTYPE x;
+#endif
check ("atanh(+0) == +0", FUNC(atanh) (0), 0);
#ifndef TEST_INLINE
@@ -1089,7 +1120,7 @@ static void
exp2_test (void)
{
errno = 0;
- exp2(0);
+ FUNC(exp2) (0);
if (errno == ENOSYS)
/* Function not implemented. */
return;
@@ -1257,7 +1288,6 @@ signbit_test (void)
check_bool ("signbit (-0) != 0", signbit (minus_zero));
check_bool ("signbit (+inf) == 0", signbit (plus_infty) == 0);
check_bool ("signbit (-inf) != 0", signbit (minus_infty));
- check_bool ("signbit (NaN) == 0", signbit (nan_value));
x = random_less (0);
check_bool ("signbit (x) != 0 for x < 0", signbit (x));
@@ -1272,21 +1302,26 @@ signbit_test (void)
static void
gamma_test (void)
{
- MATHTYPE x;
+ errno = 0;
+ FUNC(gamma) (0);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+ feclearexcept (FE_ALL_EXCEPT);
check_isinfp ("gamma (+inf) == +inf", FUNC(gamma) (plus_infty));
check_isnan_exc ("gamma (0) == NaN plus invalid exception",
FUNC(gamma) (0), INVALID_EXCEPTION);
- x = random_less (0.0);
- check_isnan_exc_ext ("gamma (x) == NaN plus invalid exception for x <= 0",
- FUNC(gamma) (x), INVALID_EXCEPTION, x);
+ check_isnan_exc_ext ("gamma (x) == NaN plus invalid exception for integer x <= 0",
+ FUNC(gamma) (-2), INVALID_EXCEPTION, -2);
check_isnan_exc ("gamma (-inf) == NaN plus invalid exception",
FUNC(gamma) (minus_infty), INVALID_EXCEPTION);
- check ("gamma (0.5) == sqrt(pi)", FUNC(gamma) (0.5), FUNC(sqrt) (M_PI));
- check ("gamma (-0.5) == -2*sqrt(pi)", FUNC(gamma) (-0.5),
- -2*FUNC(sqrt) (M_PI));
+ check_eps ("gamma (0.5) == sqrt(pi)", FUNC(gamma) (0.5), FUNC(sqrt) (M_PI),
+ CHOOSE (0, 5e-16, 2e-7));
+ check_eps ("gamma (-0.5) == -2*sqrt(pi)", FUNC(gamma) (-0.5),
+ -2*FUNC(sqrt) (M_PI), CHOOSE (0, 5e-16, 3e-7));
check ("gamma (1) == 1", FUNC(gamma) (1), 1);
check ("gamma (4) == 6", FUNC(gamma) (4), 6);
@@ -1297,15 +1332,19 @@ gamma_test (void)
static void
lgamma_test (void)
{
- MATHTYPE x;
+ errno = 0;
+ FUNC(lgamma) (0);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+ feclearexcept (FE_ALL_EXCEPT);
check_isinfp ("lgamma (+inf) == +inf", FUNC(lgamma) (plus_infty));
- check_isnan_exc ("lgamma (0) == +inf plus divide by zero exception",
- FUNC(lgamma) (0), DIVIDE_BY_ZERO_EXCEPTION);
+ check_isinfp_exc ("lgamma (0) == +inf plus divide by zero exception",
+ FUNC(lgamma) (0), DIVIDE_BY_ZERO_EXCEPTION);
- x = random_less (0.0);
- check_isnan_exc_ext ("lgamma (x) == +inf plus divide by zero exception for x <= 0",
- FUNC(lgamma) (x), DIVIDE_BY_ZERO_EXCEPTION, x);
+ check_isinfp_exc ("lgamma (x) == +inf plus divide by zero exception for integer x <= 0",
+ FUNC(lgamma) (-3), DIVIDE_BY_ZERO_EXCEPTION);
check_isnan_exc ("lgamma (-inf) == NaN plus invalid exception",
FUNC(lgamma) (minus_infty), INVALID_EXCEPTION);
@@ -1331,23 +1370,15 @@ static void
ilogb_test (void)
{
- /* XXX Are these tests correct? I couldn't find any specification */
-#if 0
- /* the source suggests that the following calls should fail -
- but shall we test these special cases or just ignore them? */
- check_isinfp ("ilogb (+inf) == +inf", FUNC(ilogb) (plus_infty));
- check_isinfp ("ilogb (-inf) == +inf", FUNC(ilogb) (minus_infty));
-
- check_isinfn_exc ("ilogb (+0) == -inf plus divide-by-zero exception",
- FUNC(ilogb) (0), DIVIDE_BY_ZERO_EXCEPTION);
+ check_int ("ilogb (1) == 0", FUNC(ilogb) (1), 0);
+ check_int ("ilogb (e) == 1", FUNC(ilogb) (M_E), 1);
+ check_int ("ilogb (1024) == 10", FUNC(ilogb) (1024), 10);
+ check_int ("ilogb (-2000) == 10", FUNC(ilogb) (-2000), 10);
- check_isinfn_exc ("ilogb (-0) == -inf plus divide-by-zero exception",
- FUNC(ilogb) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION);
-#endif
- check ("ilogb (1) == 0", FUNC(ilogb) (1), 0);
- check ("ilogb (e) == 1", FUNC(ilogb) (M_E), 1);
- check ("ilogb (1024) == 10", FUNC(ilogb) (1024), 10);
- check ("ilogb (-2000) == 10", FUNC(ilogb) (-2000), 10);
+ check_int_exc ("ilogb (0) == FP_ILOGB0", FUNC(ilogb) (0.0), FP_ILOGB0,
+ DIVIDE_BY_ZERO_EXCEPTION|INVALID_EXCEPTION);
+ check_int_exc ("ilogb (NaN) == FP_ILOGBNAN", FUNC(ilogb) (nan_value),
+ FP_ILOGBNAN, INVALID_EXCEPTION);
}
@@ -1526,17 +1557,72 @@ scalb_test (void)
{
MATHTYPE x;
- check ("scalb (0, 0) == 0", FUNC(scalb) (0, 0), 0);
+ check_isnan ("scalb (2, 0.5) == NaN", FUNC(scalb) (2, 0.5));
+ check_isnan ("scalb (3, -2.5) == NaN", FUNC(scalb) (3, -2.5));
+
+ check_isnan ("scalb (0, NaN) == NaN", FUNC(scalb) (0, nan_value));
+ check_isnan ("scalb (1, NaN) == NaN", FUNC(scalb) (1, nan_value));
+
+ x = random_greater (0.0);
+ check ("scalb (x, 0) == 0", FUNC(scalb) (x, 0), x);
+ x = random_greater (0.0);
+ check ("scalb (-x, 0) == 0", FUNC(scalb) (-x, 0), -x);
+
+ check_isnan_exc ("scalb (+0, +inf) == NaN plus invalid exception",
+ FUNC(scalb) (0, plus_infty), INVALID_EXCEPTION);
+ check_isnan_exc ("scalb (-0, +inf) == NaN plus invalid exception",
+ FUNC(scalb) (minus_zero, plus_infty), INVALID_EXCEPTION);
+
+ check ("scalb (+0, 2) == +0", FUNC(scalb) (0, 2), 0);
+ check ("scalb (-0, 4) == -0", FUNC(scalb) (minus_zero, -4), minus_zero);
+ check ("scalb (+0, 0) == +0", FUNC(scalb) (0, 0), 0);
+ check ("scalb (-0, 0) == -0", FUNC(scalb) (minus_zero, 0), minus_zero);
+ check ("scalb (+0, -1) == +0", FUNC(scalb) (0, -1), 0);
+ check ("scalb (-0, -10) == -0", FUNC(scalb) (minus_zero, -10), minus_zero);
+ check ("scalb (+0, -inf) == +0", FUNC(scalb) (0, minus_infty), 0);
+ check ("scalb (-0, -inf) == -0", FUNC(scalb) (minus_zero, minus_infty),
+ minus_zero);
+
+ check_isinfp ("scalb (+inf, -1) == +inf", FUNC(scalb) (plus_infty, -1));
+ check_isinfn ("scalb (-inf, -10) == -inf", FUNC(scalb) (minus_infty, -10));
+ check_isinfp ("scalb (+inf, 0) == +inf", FUNC(scalb) (plus_infty, 0));
+ check_isinfn ("scalb (-inf, 0) == -inf", FUNC(scalb) (minus_infty, 0));
+ check_isinfp ("scalb (+inf, 2) == +inf", FUNC(scalb) (plus_infty, 2));
+ check_isinfn ("scalb (-inf, 100) == -inf", FUNC(scalb) (minus_infty, 100));
+
+ check ("scalb (0, -inf) == 0", FUNC(scalb) (0.0, minus_infty), 0.0);
+ check ("scalb (-0, -inf) == -0", FUNC(scalb) (minus_zero, minus_infty),
+ minus_zero);
+ x = random_greater (0.0);
+ check ("scalb (x, -inf) == 0", FUNC(scalb) (x, minus_infty), 0.0);
+ check ("scalb (-x, -inf) == -0", FUNC(scalb) (-x, minus_infty), minus_zero);
+
+ x = random_greater (0.0);
+ check_isinfp ("scalb (x, +inf) == +inf", FUNC(scalb) (x, plus_infty));
+ x = random_greater (0.0);
+ check_isinfn ("scalb (-x, +inf) == -inf", FUNC(scalb) (-x, plus_infty));
+ check_isinfp ("scalb (+inf, +inf) == +inf",
+ FUNC(scalb) (plus_infty, plus_infty));
+ check_isinfn ("scalb (-inf, +inf) == -inf",
+ FUNC(scalb) (minus_infty, plus_infty));
+
+ check_isnan ("scalb (+inf, -inf) == NaN",
+ FUNC(scalb) (plus_infty, minus_infty));
+ check_isnan ("scalb (-inf, -inf) == NaN",
+ FUNC(scalb) (minus_infty, minus_infty));
- check_isinfp ("scalb (+inf, 1) == +inf", FUNC(scalb) (plus_infty, 1));
- check_isinfn ("scalb (-inf, 1) == -inf", FUNC(scalb) (minus_infty, 1));
check_isnan ("scalb (NaN, 1) == NaN", FUNC(scalb) (nan_value, 1));
+ check_isnan ("scalb (1, NaN) == NaN", FUNC(scalb) (1, nan_value));
+ check_isnan ("scalb (NaN, 0) == NaN", FUNC(scalb) (nan_value, 0));
+ check_isnan ("scalb (0, NaN) == NaN", FUNC(scalb) (0, nan_value));
+ check_isnan ("scalb (NaN, +inf) == NaN",
+ FUNC(scalb) (nan_value, plus_infty));
+ check_isnan ("scalb (+inf, NaN) == NaN",
+ FUNC(scalb) (plus_infty, nan_value));
+ check_isnan ("scalb (NaN, NaN) == NaN", FUNC(scalb) (nan_value, nan_value));
check ("scalb (0.8, 4) == 12.8", FUNC(scalb) (0.8L, 4), 12.8L);
check ("scalb (-0.854375, 5) == -27.34", FUNC(scalb) (-0.854375L, 5), -27.34L);
-
- x = random_greater (0.0);
- check_ext ("scalb (x, 0) == x", FUNC(scalb) (x, 0L), x, x);
}
@@ -1630,14 +1716,15 @@ sincos_test (void)
check ("sincos (pi/2, &sin, &cos) puts 1 in sin", sin_res, 1);
fesetenv (&fenv);
check_eps ("sincos (pi/2, &sin, &cos) puts 0 in cos", cos_res, 0,
- CHOOSE(0, 1e-16, 1e-7));
+ CHOOSE (1e-18L, 1e-16, 1e-7));
FUNC(sincos) (M_PI / 6.0, &sin_res, &cos_res);
- check ("sincos (pi/6, &sin, &cos) puts 0.5 in sin", sin_res, 0.5);
+ check_eps ("sincos (pi/6, &sin, &cos) puts 0.5 in sin", sin_res, 0.5,
+ CHOOSE (5e-18L, 0, 0));
FUNC(sincos) (M_PI / 3.0, &sin_res, &cos_res);
check_eps ("sincos (pi/3, &sin, &cos) puts 0.5 in cos", cos_res, 0.5,
- CHOOSE(0, 1e-15, 1e-7));
+ CHOOSE (5e-18L, 1e-15, 1e-7));
}
@@ -2045,13 +2132,13 @@ fmod_test (void)
FUNC(fmod) (x, minus_infty), x, x);
check_eps ("fmod (6.5, 2.3) == 1.9", FUNC(fmod) (6.5, 2.3), 1.9,
- CHOOSE(0, 1e-15, 0));
+ CHOOSE(5e-16, 1e-15, 2e-7));
check_eps ("fmod (-6.5, 2.3) == -1.9", FUNC(fmod) (-6.5, 2.3), -1.9,
- CHOOSE(0, 1e-15, 0));
+ CHOOSE(5e-16, 1e-15, 2e-7));
check_eps ("fmod (6.5, -2.3) == 1.9", FUNC(fmod) (6.5, -2.3), 1.9,
- CHOOSE(0, 1e-15, 0));
+ CHOOSE(5e-16, 1e-15, 2e-7));
check_eps ("fmod (-6.5, -2.3) == -1.9", FUNC(fmod) (-6.5, -2.3), -1.9,
- CHOOSE(0, 1e-15, 0));
+ CHOOSE(5e-16, 1e-15, 2e-7));
}
@@ -4355,44 +4442,44 @@ rint_test (void)
static void
-rinttol_test (void)
+lrint_test (void)
{
/* XXX this test is incomplete. We need to have a way to specifiy
the rounding method and test the critical cases. So far, only
unproblematic numbers are tested. */
- check_long ("rinttol(0) = 0", rinttol (0.0), 0);
- check_long ("rinttol(-0) = 0", rinttol (minus_zero), 0);
- check_long ("rinttol(0.2) = 0", rinttol (0.2), 0);
- check_long ("rinttol(-0.2) = 0", rinttol (-0.2), 0);
+ check_long ("lrint(0) = 0", lrint (0.0), 0);
+ check_long ("lrint(-0) = 0", lrint (minus_zero), 0);
+ check_long ("lrint(0.2) = 0", lrint (0.2), 0);
+ check_long ("lrint(-0.2) = 0", lrint (-0.2), 0);
- check_long ("rinttol(1.4) = 1", rinttol (1.4), 1);
- check_long ("rinttol(-1.4) = -1", rinttol (-1.4), -1);
+ check_long ("lrint(1.4) = 1", lrint (1.4), 1);
+ check_long ("lrint(-1.4) = -1", lrint (-1.4), -1);
- check_long ("rinttol(8388600.3) = 8388600", rinttol (8388600.3), 8388600);
- check_long ("rinttol(-8388600.3) = -8388600", rinttol (-8388600.3),
+ check_long ("lrint(8388600.3) = 8388600", lrint (8388600.3), 8388600);
+ check_long ("lrint(-8388600.3) = -8388600", lrint (-8388600.3),
-8388600);
}
static void
-rinttoll_test (void)
+llrint_test (void)
{
/* XXX this test is incomplete. We need to have a way to specifiy
the rounding method and test the critical cases. So far, only
unproblematic numbers are tested. */
- check_longlong ("rinttoll(0) = 0", rinttoll (0.0), 0);
- check_longlong ("rinttoll(-0) = 0", rinttoll (minus_zero), 0);
- check_longlong ("rinttoll(0.2) = 0", rinttoll (0.2), 0);
- check_longlong ("rinttoll(-0.2) = 0", rinttoll (-0.2), 0);
+ check_longlong ("llrint(0) = 0", llrint (0.0), 0);
+ check_longlong ("llrint(-0) = 0", llrint (minus_zero), 0);
+ check_longlong ("llrint(0.2) = 0", llrint (0.2), 0);
+ check_longlong ("llrint(-0.2) = 0", llrint (-0.2), 0);
- check_longlong ("rinttoll(1.4) = 1", rinttoll (1.4), 1);
- check_longlong ("rinttoll(-1.4) = -1", rinttoll (-1.4), -1);
+ check_longlong ("llrint(1.4) = 1", llrint (1.4), 1);
+ check_longlong ("llrint(-1.4) = -1", llrint (-1.4), -1);
- check_longlong ("rinttoll(8388600.3) = 8388600", rinttoll (8388600.3),
+ check_longlong ("llrint(8388600.3) = 8388600", llrint (8388600.3),
8388600);
- check_longlong ("rinttoll(-8388600.3) = -8388600", rinttoll (-8388600.3),
+ check_longlong ("llrint(-8388600.3) = -8388600", llrint (-8388600.3),
-8388600);
}
@@ -4416,45 +4503,45 @@ round_test (void)
static void
-roundtol_test (void)
+lround_test (void)
{
- check_long ("roundtol(0) = 0", roundtol (0), 0);
- check_long ("roundtol(-0) = 0", roundtol (minus_zero), 0);
- check_long ("roundtol(0.2) = 0", roundtol (0.2), 0.0);
- check_long ("roundtol(-0.2) = 0", roundtol (-0.2), 0);
- check_long ("roundtol(0.5) = 1", roundtol (0.5), 1);
- check_long ("roundtol(-0.5) = -1", roundtol (-0.5), -1);
- check_long ("roundtol(0.8) = 1", roundtol (0.8), 1);
- check_long ("roundtol(-0.8) = -1", roundtol (-0.8), -1);
- check_long ("roundtol(1.5) = 2", roundtol (1.5), 2);
- check_long ("roundtol(-1.5) = -2", roundtol (-1.5), -2);
- check_long ("roundtol(2097152.5) = 2097153", roundtol (2097152.5), 2097153);
- check_long ("roundtol(-2097152.5) = -2097153", roundtol (-2097152.5),
+ check_long ("lround(0) = 0", lround (0), 0);
+ check_long ("lround(-0) = 0", lround (minus_zero), 0);
+ check_long ("lround(0.2) = 0", lround (0.2), 0.0);
+ check_long ("lround(-0.2) = 0", lround (-0.2), 0);
+ check_long ("lround(0.5) = 1", lround (0.5), 1);
+ check_long ("lround(-0.5) = -1", lround (-0.5), -1);
+ check_long ("lround(0.8) = 1", lround (0.8), 1);
+ check_long ("lround(-0.8) = -1", lround (-0.8), -1);
+ check_long ("lround(1.5) = 2", lround (1.5), 2);
+ check_long ("lround(-1.5) = -2", lround (-1.5), -2);
+ check_long ("lround(2097152.5) = 2097153", lround (2097152.5), 2097153);
+ check_long ("lround(-2097152.5) = -2097153", lround (-2097152.5),
-2097153);
}
static void
-roundtoll_test (void)
+llround_test (void)
{
- check_longlong ("roundtoll(0) = 0", roundtoll (0), 0);
- check_longlong ("roundtoll(-0) = 0", roundtoll (minus_zero), 0);
- check_longlong ("roundtoll(0.2) = 0", roundtoll (0.2), 0.0);
- check_longlong ("roundtoll(-0.2) = 0", roundtoll (-0.2), 0);
- check_longlong ("roundtoll(0.5) = 1", roundtoll (0.5), 1);
- check_longlong ("roundtoll(-0.5) = -1", roundtoll (-0.5), -1);
- check_longlong ("roundtoll(0.8) = 1", roundtoll (0.8), 1);
- check_longlong ("roundtoll(-0.8) = -1", roundtoll (-0.8), -1);
- check_longlong ("roundtoll(1.5) = 2", roundtoll (1.5), 2);
- check_longlong ("roundtoll(-1.5) = -2", roundtoll (-1.5), -2);
- check_longlong ("roundtoll(2097152.5) = 2097153",
- roundtoll (2097152.5), 2097153);
- check_longlong ("roundtoll(-2097152.5) = -2097153",
- roundtoll (-2097152.5), -2097153);
- check_longlong ("roundtoll(34359738368.5) = 34359738369",
- roundtoll (34359738368.5), 34359738369ll);
- check_longlong ("roundtoll(-34359738368.5) = -34359738369",
- roundtoll (-34359738368.5), -34359738369ll);
+ check_longlong ("llround(0) = 0", llround (0), 0);
+ check_longlong ("llround(-0) = 0", llround (minus_zero), 0);
+ check_longlong ("llround(0.2) = 0", llround (0.2), 0.0);
+ check_longlong ("llround(-0.2) = 0", llround (-0.2), 0);
+ check_longlong ("llround(0.5) = 1", llround (0.5), 1);
+ check_longlong ("llround(-0.5) = -1", llround (-0.5), -1);
+ check_longlong ("llround(0.8) = 1", llround (0.8), 1);
+ check_longlong ("llround(-0.8) = -1", llround (-0.8), -1);
+ check_longlong ("llround(1.5) = 2", llround (1.5), 2);
+ check_longlong ("llround(-1.5) = -2", llround (-1.5), -2);
+ check_longlong ("llround(2097152.5) = 2097153",
+ llround (2097152.5), 2097153);
+ check_longlong ("llround(-2097152.5) = -2097153",
+ llround (-2097152.5), -2097153);
+ check_longlong ("llround(34359738368.5) = 34359738369",
+ llround (34359738368.5), 34359738369ll);
+ check_longlong ("llround(-34359738368.5) = -34359738369",
+ llround (-34359738368.5), -34359738369ll);
}
@@ -4811,11 +4898,11 @@ main (int argc, char *argv[])
floor_test ();
nearbyint_test ();
rint_test ();
- rinttol_test ();
- rinttoll_test ();
+ lrint_test ();
+ llrint_test ();
round_test ();
- roundtol_test ();
- roundtoll_test ();
+ lround_test ();
+ llround_test ();
trunc_test ();
/* remainder functions */
diff --git a/math/math.h b/math/math.h
index 5229a02..aa37f71 100644
--- a/math/math.h
+++ b/math/math.h
@@ -186,13 +186,13 @@ enum
/* Round X to nearest integral value according to current rounding
direction. */
-extern long int rinttol __P ((long double __x));
-extern long long int rinttoll __P ((long double __x));
+extern long int lrint __P ((long double __x));
+extern long long int llrint __P ((long double __x));
/* Round X to nearest integral value, rounding halfway cases away from
zero. */
-extern long int roundtol __P ((long double __x));
-extern long long int roundtoll __P ((long double __x));
+extern long int lround __P ((long double __x));
+extern long long int llround __P ((long double __x));
/* Comparison macros. */
diff --git a/math/mathcalls.h b/math/mathcalls.h
index 0aac420..735b595 100644
--- a/math/mathcalls.h
+++ b/math/mathcalls.h
@@ -138,9 +138,7 @@ __MATHCALL (sqrt,, (_Mdouble_ __x));
#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC9X
/* Return `sqrt(X*X + Y*Y)'. */
__MATHCALL (hypot,, (_Mdouble_ __x, _Mdouble_ __y));
-#endif
-#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
/* Return the cube root of X. */
__MATHCALL (cbrt,, (_Mdouble_ __x));
#endif
@@ -177,9 +175,6 @@ __MATHDECLX (int,finite,, (_Mdouble_ __value), (__const__));
and may return an infinity or NaN, or may do something else. */
__MATHCALLX (infnan,, (int __error), (__const__));
-/* Return X times (2 to the Nth power). */
-__MATHCALL (scalbn,, (_Mdouble_ __x, int __n));
-
/* Return the remainder of X/Y. */
__MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y));
@@ -203,9 +198,6 @@ __MATHCALLX (nan,, (__const char *__tagb), (__const__));
/* Return nonzero if VALUE is not a number. */
__MATHDECLX (int,isnan,, (_Mdouble_ __value), (__const__));
-/* Return the binary exponent of X, which must be nonzero. */
-__MATHDECL (int,ilogb,, (_Mdouble_ __x));
-
/* Bessel functions. */
__MATHCALL (j0,, (_Mdouble_));
__MATHCALL (j1,, (_Mdouble_));
@@ -222,6 +214,7 @@ __MATHCALL (erf,, (_Mdouble_));
__MATHCALL (erfc,, (_Mdouble_));
__MATHCALL (gamma,, (_Mdouble_));
__MATHCALL (lgamma,, (_Mdouble_));
+#endif
#ifdef __USE_MISC
/* Reentrant versions of gamma and lgamma. Those functions use the global
@@ -231,8 +224,6 @@ __MATHCALL (gamma,_r, (_Mdouble_, int *));
__MATHCALL (lgamma,_r, (_Mdouble_, int *));
#endif
-#endif /* Use misc or X/Open. */
-
#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC9X
/* Return the integer nearest X in the direction of the
@@ -244,11 +235,15 @@ __MATHCALLX (nextafter,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
/* Return the remainder of integer divison X / Y with infinite precision. */
__MATHCALL (remainder,, (_Mdouble_ __x, _Mdouble_ __y));
-#endif
-#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
/* Return X times (2 to the Nth power). */
__MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n));
+
+/* Return X times (2 to the Nth power). */
+__MATHCALL (scalbn,, (_Mdouble_ __x, long int __n));
+
+/* Return the binary exponent of X, which must be nonzero. */
+__MATHDECL (int,ilogb,, (_Mdouble_ __x));
#endif
#ifdef __USE_ISOC9X