annotate m4/fmal.m4 @ 17451:1c64d8246a92

tmpdir: fix typo in previous change
author Paul Eggert <eggert@cs.ucla.edu>
date Mon, 15 Jul 2013 14:43:20 -0700
parents e542fd46ad6f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16935
498a2211d839 Write "Mac OS X" instead of "MacOS X".
Bruno Haible <bruno@clisp.org>
parents: 16611
diff changeset
1 # fmal.m4 serial 4
17249
e542fd46ad6f maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents: 16935
diff changeset
2 dnl Copyright (C) 2011-2013 Free Software Foundation, Inc.
16042
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 dnl This file is free software; the Free Software Foundation
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 AC_DEFUN([gl_FUNC_FMAL],
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 [
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 AC_REQUIRE([gl_MATH_H_DEFAULTS])
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11
16580
fdbe3125f81a math: Ensure declarations of math functions.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
12 dnl Persuade glibc <math.h> to declare fmal().
fdbe3125f81a math: Ensure declarations of math functions.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
fdbe3125f81a math: Ensure declarations of math functions.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
14
16042
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 dnl Determine FMAL_LIBM.
16611
b0c15a5d5038 fma, fmaf, fmal: Override undeclared system functions on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents: 16580
diff changeset
16 gl_MATHFUNC([fmal], [long double], [(long double, long double, long double)],
b0c15a5d5038 fma, fmaf, fmal: Override undeclared system functions on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents: 16580
diff changeset
17 [extern
b0c15a5d5038 fma, fmaf, fmal: Override undeclared system functions on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents: 16580
diff changeset
18 #ifdef __cplusplus
b0c15a5d5038 fma, fmaf, fmal: Override undeclared system functions on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents: 16580
diff changeset
19 "C"
b0c15a5d5038 fma, fmaf, fmal: Override undeclared system functions on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents: 16580
diff changeset
20 #endif
b0c15a5d5038 fma, fmaf, fmal: Override undeclared system functions on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents: 16580
diff changeset
21 long double fmal (long double, long double, long double);
b0c15a5d5038 fma, fmaf, fmal: Override undeclared system functions on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents: 16580
diff changeset
22 ])
16042
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 if test $gl_cv_func_fmal_no_libm = yes \
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 || test $gl_cv_func_fmal_in_libm = yes; then
16611
b0c15a5d5038 fma, fmaf, fmal: Override undeclared system functions on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents: 16580
diff changeset
25 dnl Also check whether it's declared.
b0c15a5d5038 fma, fmaf, fmal: Override undeclared system functions on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents: 16580
diff changeset
26 dnl IRIX 6.5 has fmal() in libm but doesn't declare it in <math.h>,
b0c15a5d5038 fma, fmaf, fmal: Override undeclared system functions on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents: 16580
diff changeset
27 dnl and the function is buggy.
b0c15a5d5038 fma, fmaf, fmal: Override undeclared system functions on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents: 16580
diff changeset
28 AC_CHECK_DECL([fmal], , [REPLACE_FMAL=1], [[#include <math.h>]])
b0c15a5d5038 fma, fmaf, fmal: Override undeclared system functions on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents: 16580
diff changeset
29 if test $REPLACE_FMAL = 0; then
b0c15a5d5038 fma, fmaf, fmal: Override undeclared system functions on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents: 16580
diff changeset
30 gl_FUNC_FMAL_WORKS
b0c15a5d5038 fma, fmaf, fmal: Override undeclared system functions on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents: 16580
diff changeset
31 case "$gl_cv_func_fmal_works" in
b0c15a5d5038 fma, fmaf, fmal: Override undeclared system functions on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents: 16580
diff changeset
32 *no) REPLACE_FMAL=1 ;;
b0c15a5d5038 fma, fmaf, fmal: Override undeclared system functions on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents: 16580
diff changeset
33 esac
b0c15a5d5038 fma, fmaf, fmal: Override undeclared system functions on IRIX 6.5.
Bruno Haible <bruno@clisp.org>
parents: 16580
diff changeset
34 fi
16042
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 else
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 HAVE_FMAL=0
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 fi
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 if test $HAVE_FMAL = 0 || test $REPLACE_FMAL = 1; then
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 dnl Find libraries needed to link lib/fmal.c.
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 AC_REQUIRE([gl_FUNC_FMA])
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 FMAL_LIBM="$FMA_LIBM"
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 else
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 AC_REQUIRE([gl_FUNC_FREXPL])
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 AC_REQUIRE([gl_FUNC_LDEXPL])
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 AC_REQUIRE([gl_FUNC_FEGETROUND])
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 FMAL_LIBM=
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 dnl Append $FREXPL_LIBM to FMAL_LIBM, avoiding gratuitous duplicates.
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 case " $FMAL_LIBM " in
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 *" $FREXPL_LIBM "*) ;;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 *) FMAL_LIBM="$FMAL_LIBM $FREXPL_LIBM" ;;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 esac
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 dnl Append $LDEXPL_LIBM to FMAL_LIBM, avoiding gratuitous duplicates.
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 case " $FMAL_LIBM " in
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 *" $LDEXPL_LIBM "*) ;;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 *) FMAL_LIBM="$FMAL_LIBM $LDEXPL_LIBM" ;;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 esac
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 dnl Append $FEGETROUND_LIBM to FMAL_LIBM, avoiding gratuitous duplicates.
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 case " $FMAL_LIBM " in
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 *" $FEGETROUND_LIBM "*) ;;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 *) FMAL_LIBM="$FMAL_LIBM $FEGETROUND_LIBM" ;;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 esac
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 fi
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64 fi
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 AC_SUBST([FMAL_LIBM])
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66 ])
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
67
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 dnl Test whether fmal() has any of the 15 known bugs of glibc 2.11.3 on x86_64.
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69 AC_DEFUN([gl_FUNC_FMAL_WORKS],
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
70 [
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
71 AC_REQUIRE([AC_PROG_CC])
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
72 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
73 AC_REQUIRE([gl_FUNC_LDEXPL])
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
74 save_LIBS="$LIBS"
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
75 LIBS="$LIBS $FMAL_LIBM $LDEXPL_LIBM"
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
76 AC_CACHE_CHECK([whether fmal works], [gl_cv_func_fmal_works],
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
77 [
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
78 AC_RUN_IFELSE(
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
79 [AC_LANG_SOURCE([[
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
80 #include <float.h>
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
81 #include <math.h>
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
82 /* Override the values of <float.h>, like done in float.in.h. */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
83 #if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__)
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
84 # undef LDBL_MANT_DIG
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
85 # define LDBL_MANT_DIG 64
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
86 # undef LDBL_MIN_EXP
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
87 # define LDBL_MIN_EXP (-16381)
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
88 # undef LDBL_MAX_EXP
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
89 # define LDBL_MAX_EXP 16384
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
90 #endif
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
91 #if defined __i386__ && defined __FreeBSD__
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
92 # undef LDBL_MANT_DIG
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
93 # define LDBL_MANT_DIG 64
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
94 # undef LDBL_MIN_EXP
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
95 # define LDBL_MIN_EXP (-16381)
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
96 # undef LDBL_MAX_EXP
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
97 # define LDBL_MAX_EXP 16384
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
98 #endif
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
99 #if (defined _ARCH_PPC || defined _POWER) && defined _AIX && (LDBL_MANT_DIG == 106) && defined __GNUC__
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
100 # undef LDBL_MIN_EXP
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
101 # define LDBL_MIN_EXP DBL_MIN_EXP
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
102 #endif
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
103 #if defined __sgi && (LDBL_MANT_DIG >= 106)
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
104 # undef LDBL_MANT_DIG
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
105 # define LDBL_MANT_DIG 106
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
106 # if defined __GNUC__
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
107 # undef LDBL_MIN_EXP
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
108 # define LDBL_MIN_EXP DBL_MIN_EXP
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
109 # endif
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
110 #endif
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
111 long double p0 = 0.0L;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
112 int main()
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
113 {
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
114 int failed_tests = 0;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
115 /* This test fails on glibc 2.11 powerpc. */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
116 {
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
117 volatile long double x = 1.5L; /* 3 * 2^-1 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
118 volatile long double y = x;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
119 volatile long double z = ldexpl (1.0L, LDBL_MANT_DIG + 1); /* 2^65 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
120 /* x * y + z with infinite precision: 2^65 + 9 * 2^-2.
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
121 Lies between (2^63 + 0) * 2^2 and (2^63 + 1) * 2^2
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
122 and is closer to (2^63 + 1) * 2^2, therefore the rounding
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
123 must round up and produce (2^63 + 1) * 2^2. */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
124 volatile long double expected = z + 4.0L;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
125 volatile long double result = fmal (x, y, z);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
126 if (result != expected)
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
127 failed_tests |= 1;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
128 }
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
129 /* This test fails on glibc 2.11 powerpc. */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
130 {
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
131 volatile long double x = 1.25L; /* 2^0 + 2^-2 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
132 volatile long double y = - x;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
133 volatile long double z = ldexpl (1.0L, LDBL_MANT_DIG + 1); /* 2^65 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
134 /* x * y + z with infinite precision: 2^65 - 2^0 - 2^-1 - 2^-4.
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
135 Lies between (2^64 - 1) * 2^1 and 2^64 * 2^1
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
136 and is closer to (2^64 - 1) * 2^1, therefore the rounding
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
137 must round down and produce (2^64 - 1) * 2^1. */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
138 volatile long double expected = (ldexpl (1.0L, LDBL_MANT_DIG) - 1.0L) * 2.0L;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
139 volatile long double result = fmal (x, y, z);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
140 if (result != expected)
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
141 failed_tests |= 1;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
142 }
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
143 /* This test fails on glibc 2.11 x86,x86_64,powerpc, glibc 2.7 hppa,sparc,
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
144 OSF/1 5.1, mingw. */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
145 {
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
146 volatile long double x = 1.0L + ldexpl (1.0L, 1 - LDBL_MANT_DIG); /* 2^0 + 2^-63 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
147 volatile long double y = x;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
148 volatile long double z = 4.0L; /* 2^2 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
149 /* x * y + z with infinite precision: 2^2 + 2^0 + 2^-62 + 2^-126.
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
150 Lies between (2^63 + 2^61) * 2^-61 and (2^63 + 2^61 + 1) * 2^-61
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
151 and is closer to (2^63 + 2^61 + 1) * 2^-61, therefore the rounding
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
152 must round up and produce (2^63 + 2^61 + 1) * 2^-61. */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
153 volatile long double expected = 4.0L + 1.0L + ldexpl (1.0L, 3 - LDBL_MANT_DIG);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
154 volatile long double result = fmal (x, y, z);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
155 if (result != expected)
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
156 failed_tests |= 2;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
157 }
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
158 /* This test fails on glibc 2.11 x86,x86_64,powerpc glibc 2.7 hppa,sparc,
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
159 OSF/1 5.1, mingw. */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
160 {
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
161 volatile long double x = 1.0L + ldexpl (1.0L, 1 - LDBL_MANT_DIG); /* 2^0 + 2^-63 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
162 volatile long double y = - x;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
163 volatile long double z = 8.0L; /* 2^3 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
164 /* x * y + z with infinite precision: 2^2 + 2^1 + 2^0 - 2^-62 - 2^-126.
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
165 Lies between (2^63 + 2^62 + 2^61 - 1) * 2^-61 and
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
166 (2^63 + 2^62 + 2^61) * 2^-61 and is closer to
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
167 (2^63 + 2^62 + 2^61 - 1) * 2^-61, therefore the rounding
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
168 must round down and produce (2^63 + 2^62 + 2^61 - 1) * 2^-61. */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
169 volatile long double expected = 7.0L - ldexpl (1.0L, 3 - LDBL_MANT_DIG);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
170 volatile long double result = fmal (x, y, z);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
171 if (result != expected)
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
172 failed_tests |= 2;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
173 }
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
174 /* This test fails on glibc 2.11 powerpc. */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
175 {
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
176 volatile long double x = 1.25L; /* 2^0 + 2^-2 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
177 volatile long double y = - 0.75L; /* - 2^0 + 2^-2 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
178 volatile long double z = ldexpl (1.0L, LDBL_MANT_DIG); /* 2^64 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
179 /* x * y + z with infinite precision: 2^64 - 2^0 + 2^-4.
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
180 Lies between (2^64 - 2^0) and 2^64 and is closer to (2^64 - 2^0),
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
181 therefore the rounding must round down and produce (2^64 - 2^0). */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
182 volatile long double expected = ldexpl (1.0L, LDBL_MANT_DIG) - 1.0L;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
183 volatile long double result = fmal (x, y, z);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
184 if (result != expected)
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
185 failed_tests |= 1;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
186 }
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
187 if ((LDBL_MANT_DIG % 2) == 1)
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
188 {
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
189 /* These tests fail on glibc 2.7 hppa,sparc, OSF/1 5.1. */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
190 {
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
191 volatile long double x = 1.0L + ldexpl (1.0L, - (LDBL_MANT_DIG + 1) / 2); /* 2^0 + 2^-27 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
192 volatile long double y = 1.0L - ldexpl (1.0L, - (LDBL_MANT_DIG + 1) / 2); /* 2^0 - 2^-27 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
193 volatile long double z = - ldexpl (1.0L, LDBL_MIN_EXP - LDBL_MANT_DIG); /* - 2^-1074 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
194 /* x * y + z with infinite precision: 2^0 - 2^-54 - 2^-1074.
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
195 Lies between (2^53 - 1) * 2^-53 and 2^53 * 2^-53 and is closer to
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
196 (2^53 - 1) * 2^-53, therefore the rounding must round down and
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
197 produce (2^53 - 1) * 2^-53. */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
198 volatile long double expected = 1.0L - ldexpl (1.0L, - LDBL_MANT_DIG);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
199 volatile long double result = fmal (x, y, z);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
200 if (result != expected)
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
201 failed_tests |= 4;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
202 }
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
203 {
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
204 volatile long double x = 1.0L + ldexpl (1.0L, - (LDBL_MANT_DIG + 1) / 2); /* 2^0 + 2^-57 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
205 volatile long double y = x;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
206 volatile long double z = ldexpl (1.0L, - LDBL_MANT_DIG); /* 2^-113 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
207 /* x * y + z with infinite precision: 2^0 + 2^-56 + 2^-113 + 2^-114.
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
208 Lies between (2^112 + 2^56) * 2^-112 and (2^112 + 2^56 + 1) * 2^-112
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
209 and is closer to (2^112 + 2^56 + 1) * 2^-112, therefore the rounding
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
210 must round up and produce (2^112 + 2^56 + 1) * 2^-112. */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
211 volatile long double expected =
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
212 1.0L + ldexpl (1.0L, - (LDBL_MANT_DIG - 1) / 2) + ldexpl (1.0L, 1 - LDBL_MANT_DIG);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
213 volatile long double result = fmal (x, y, z);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
214 if (result != expected)
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
215 failed_tests |= 4;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
216 }
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
217 }
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
218 else
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
219 {
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
220 /* These tests fail on glibc 2.11 x86,x86_64,powerpc, mingw. */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
221 {
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
222 volatile long double x = 1.0L + ldexpl (1.0L, - LDBL_MANT_DIG / 2); /* 2^0 + 2^-32 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
223 volatile long double y = x;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
224 volatile long double z = ldexpl (1.0L, LDBL_MIN_EXP - LDBL_MANT_DIG); /* 2^-16445 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
225 /* x * y + z with infinite precision: 2^0 + 2^-31 + 2^-64 + 2^-16445.
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
226 Lies between (2^63 + 2^32 + 0) * 2^-63 and (2^63 + 2^32 + 1) * 2^-63
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
227 and is closer to (2^63 + 2^32 + 1) * 2^-63, therefore the rounding
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
228 must round up and produce (2^63 + 2^32 + 1) * 2^-63. */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
229 volatile long double expected =
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
230 1.0L + ldexpl (1.0L, 1 - LDBL_MANT_DIG / 2) + ldexpl (1.0L, 1 - LDBL_MANT_DIG);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
231 volatile long double result = fmal (x, y, z);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
232 if (result != expected)
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
233 failed_tests |= 8;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
234 }
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
235 {
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
236 volatile long double x = 1.0L + ldexpl (1.0L, - LDBL_MANT_DIG / 2); /* 2^0 + 2^-32 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
237 volatile long double y = x;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
238 volatile long double z = ldexpl (1.0L, - LDBL_MANT_DIG); /* 2^-64 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
239 /* x * y + z with infinite precision: 2^0 + 2^-31 + 2^-63.
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
240 Rounding must return this value unchanged. */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
241 volatile long double expected = 1.0L + ldexpl (1.0L, 1 - LDBL_MANT_DIG / 2) + ldexpl (1.0L, 1 - LDBL_MANT_DIG);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
242 volatile long double result = fmal (x, y, z);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
243 if (result != expected)
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
244 failed_tests |= 8;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
245 }
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
246 {
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
247 volatile long double x = 1.0L + ldexpl (1.0L, - LDBL_MANT_DIG / 2); /* 2^0 + 2^-32 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
248 volatile long double y = x;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
249 volatile long double z = ldexpl (1.0L, 1 - LDBL_MANT_DIG); /* 2^-63 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
250 /* x * y + z with infinite precision: 2^0 + 2^-31 + 2^-63 + 2^-64.
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
251 Lies between (2^63 + 2^32 + 1) * 2^-63 and (2^63 + 2^32 + 2) * 2^-63
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
252 and is at the same distance from each. According to the round-to-even
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
253 rule, the rounding must round up and produce (2^63 + 2^32 + 2) * 2^-63. */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
254 volatile long double expected = 1.0L + ldexpl (1.0L, -31) + ldexpl (1.0L, -62);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
255 volatile long double result = fmal (x, y, z);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
256 if (result != expected)
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
257 failed_tests |= 8;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
258 }
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
259 {
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
260 volatile long double x = 1.0L + ldexpl (1.0L, - LDBL_MANT_DIG / 2); /* 2^0 + 2^-32 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
261 volatile long double y = x;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
262 volatile long double z = ldexpl (1.0L, LDBL_MANT_DIG / 2 + 1); /* 2^33 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
263 /* x * y + z with infinite precision: 2^33 + 2^0 + 2^-31 + 2^-64.
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
264 Lies between (2^63 + 2^30) * 2^-30 and (2^63 + 2^30 + 1) * 2^-30
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
265 and is closer to (2^63 + 2^30 + 1) * 2^-30, therefore the rounding
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
266 must round up and produce (2^63 + 2^30 + 1) * 2^-30. */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
267 volatile long double expected = z + 1.0L + ldexp (1.0L, 2 - LDBL_MANT_DIG / 2);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
268 volatile long double result = fmal (x, y, z);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
269 if (result != expected)
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
270 failed_tests |= 8;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
271 }
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
272 {
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
273 volatile long double x = 1.0L + ldexpl (1.0L, - LDBL_MANT_DIG / 2); /* 2^0 + 2^-32 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
274 volatile long double y = x;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
275 volatile long double z = - ldexpl (1.0, 1 - LDBL_MANT_DIG); /* - 2^-63 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
276 /* x * y + z with infinite precision: 2^0 + 2^-31 - 2^-64.
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
277 Lies between (2^63 + 2^32 - 1) * 2^-63 and (2^63 + 2^32) * 2^-63
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
278 and is at the same distance from each. According to the round-to-even
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
279 rule, the rounding must round up and produce (2^63 + 2^32) * 2^-63. */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
280 volatile long double expected = 1.0L + ldexpl (1.0L, 1 - LDBL_MANT_DIG / 2);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
281 volatile long double result = fmal (x, y, z);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
282 if (result != expected)
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
283 failed_tests |= 8;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
284 }
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
285 {
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
286 volatile long double x = 1.0L + ldexpl (1.0L, - LDBL_MANT_DIG / 2); /* 2^0 + 2^-32 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
287 volatile long double y = x;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
288 volatile long double z = - 1.0L; /* - 2^0 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
289 /* x * y + z with infinite precision: 2^-31 + 2^-64.
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
290 Rounding must return this value unchanged. */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
291 volatile long double expected = ldexpl (1.0L, 1 - LDBL_MANT_DIG / 2) + ldexpl (1.0L, - LDBL_MANT_DIG);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
292 volatile long double result = fmal (x, y, z);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
293 if (result != expected)
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
294 failed_tests |= 8;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
295 }
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
296 {
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
297 volatile long double x = 1.0L + ldexpl (1.0L, - LDBL_MANT_DIG / 2); /* 2^0 + 2^-32 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
298 volatile long double y = - x;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
299 volatile long double z = 2.0L; /* 2^1 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
300 /* x * y + z with infinite precision: 2^0 - 2^31 - 2^-64.
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
301 Rounding must return this value unchanged. */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
302 volatile long double expected = 1.0L - ldexpl (1.0L, 1 - LDBL_MANT_DIG / 2) - ldexpl (1.0L, - LDBL_MANT_DIG);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
303 volatile long double result = fmal (x, y, z);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
304 if (result != expected)
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
305 failed_tests |= 8;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
306 }
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
307 {
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
308 volatile long double x = 1.0L + ldexpl (1.0L, - LDBL_MANT_DIG / 2); /* 2^0 + 2^-32 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
309 volatile long double y = - x;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
310 volatile long double z = ldexpl (1.0L, LDBL_MANT_DIG / 2 + 2); /* 2^34 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
311 /* x * y + z with infinite precision: 2^34 - (2^0 + 2^-31 + 2^-64).
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
312 Lies between (2^64 - 2^30 - 1) * 2^-30 and (2^64 - 2^30) * 2^-30
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
313 and is closer to (2^64 - 2^30 - 1) * 2^-30, therefore the rounding
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
314 must round down and produce (2^64 - 2^30 - 1) * 2^-30. */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
315 volatile long double expected = z - 1.0L - ldexpl (1.0L, 2 - LDBL_MANT_DIG / 2);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
316 volatile long double result = fmal (x, y, z);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
317 if (result != expected)
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
318 failed_tests |= 8;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
319 }
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
320 {
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
321 volatile long double x = 1.0L + ldexpl (1.0L, - LDBL_MANT_DIG / 2 - 1); /* 2^0 + 2^-33 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
322 volatile long double y = 1.0L - ldexpl (1.0L, - LDBL_MANT_DIG / 2 - 1); /* 2^0 - 2^-33 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
323 volatile long double z = - ldexpl (1.0L, - LDBL_MANT_DIG - 1); /* 2^-65 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
324 /* x * y + z with infinite precision: 2^0 - 2^-65 - 2^-66.
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
325 Lies between (2^64 - 1) * 2^-64 and 2^64 * 2^-64 and is closer to
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
326 (2^64 - 1) * 2^-64, therefore the rounding must round down and
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
327 produce (2^64 - 1) * 2^-64. */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
328 volatile long double expected = 1.0L - ldexpl (1.0L, - LDBL_MANT_DIG);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
329 volatile long double result = fmal (x, y, z);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
330 if (result != expected)
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
331 failed_tests |= 8;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
332 }
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
333 {
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
334 volatile long double x = 1.0L + ldexpl (1.0L, - LDBL_MANT_DIG / 2 - 1); /* 2^0 + 2^-33 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
335 volatile long double y = 1.0L - ldexpl (1.0L, - LDBL_MANT_DIG / 2 - 1); /* 2^0 - 2^-33 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
336 volatile long double z = - 1.0L; /* 2^0 */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
337 /* x * y + z with infinite precision: - 2^-66.
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
338 Rounding must return this value unchanged. */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
339 volatile long double expected = - ldexpl (1.0L, - LDBL_MANT_DIG - 2);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
340 volatile long double result = fmal (x, y, z);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
341 if (result != expected)
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
342 failed_tests |= 8;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
343 }
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
344 }
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
345 /* This test fails on glibc 2.11 x86,x86_64,powerpc, glibc 2.7 hppa,sparc,
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
346 FreeBSD 6.4 x86, mingw. */
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
347 {
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
348 long double minus_inf = -1.0L / p0;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
349 volatile long double x = ldexpl (1.0L, LDBL_MAX_EXP - 1);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
350 volatile long double y = ldexpl (1.0L, LDBL_MAX_EXP - 1);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
351 volatile long double z = minus_inf;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
352 volatile long double result = fmal (x, y, z);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
353 if (!(result == minus_inf))
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
354 failed_tests |= 16;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
355 }
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
356 /* This test fails on glibc 2.11 x86,x86_64,powerpc glibc 2.7 hppa,sparc,
16935
498a2211d839 Write "Mac OS X" instead of "MacOS X".
Bruno Haible <bruno@clisp.org>
parents: 16611
diff changeset
357 Mac OS X 10.5, FreeBSD 6.4 x86, OSF/1 5.1, mingw. */
16042
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
358 {
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
359 volatile long double x = ldexpl (1.0L, LDBL_MAX_EXP - 1);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
360 volatile long double y = 2.0L;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
361 volatile long double z =
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
362 - ldexpl (ldexpl (1.0L, LDBL_MAX_EXP - 1) - ldexpl (1.0L, LDBL_MAX_EXP - LDBL_MANT_DIG - 1), 1);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
363 volatile long double expected = ldexpl (1.0L, LDBL_MAX_EXP - LDBL_MANT_DIG);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
364 volatile long double result = fmal (x, y, z);
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
365 if (result != expected)
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
366 failed_tests |= 32;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
367 }
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
368 return failed_tests;
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
369 }]])],
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
370 [gl_cv_func_fmal_works=yes],
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
371 [gl_cv_func_fmal_works=no],
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
372 [dnl Guess no, even on glibc systems.
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
373 gl_cv_func_fmal_works="guessing no"
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
374 ])
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
375 ])
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
376 LIBS="$save_LIBS"
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
377 ])
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
378
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
379 # Prerequisites of lib/fmal.c.
40ce19578aff New module 'fmal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
380 AC_DEFUN([gl_PREREQ_FMAL], [:])