1 /* Test of multiplying a 'long double' by a power of 2.
2 Copyright (C) 2007-2011 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2007. */
23 #include "signature.h"
24 SIGNATURE_CHECK (ldexpl, long double, (long double, int));
29 #include "isnanl-nolibm.h"
30 #include "minus-zero.h"
41 DECL_LONG_DOUBLE_ROUNDING
43 BEGIN_LONG_DOUBLE_ROUNDING ();
47 y = ldexpl (x, 0); ASSERT (isnanl (y));
48 y = ldexpl (x, 5); ASSERT (isnanl (y));
49 y = ldexpl (x, -5); ASSERT (isnanl (y));
52 { /* Positive infinity. */
54 y = ldexpl (x, 0); ASSERT (y == x);
55 y = ldexpl (x, 5); ASSERT (y == x);
56 y = ldexpl (x, -5); ASSERT (y == x);
59 { /* Negative infinity. */
61 y = ldexpl (x, 0); ASSERT (y == x);
62 y = ldexpl (x, 5); ASSERT (y == x);
63 y = ldexpl (x, -5); ASSERT (y == x);
66 { /* Positive zero. */
68 y = ldexpl (x, 0); ASSERT (y == x); ASSERT (!signbit (x));
69 y = ldexpl (x, 5); ASSERT (y == x); ASSERT (!signbit (x));
70 y = ldexpl (x, -5); ASSERT (y == x); ASSERT (!signbit (x));
73 { /* Negative zero. */
75 y = ldexpl (x, 0); ASSERT (y == x); ASSERT (signbit (x));
76 y = ldexpl (x, 5); ASSERT (y == x); ASSERT (signbit (x));
77 y = ldexpl (x, -5); ASSERT (y == x); ASSERT (signbit (x));
80 { /* Positive finite number. */
82 y = ldexpl (x, 0); ASSERT (y == x);
83 y = ldexpl (x, 5); ASSERT (y == x * 32.0L);
84 y = ldexpl (x, -5); ASSERT (y == x * 0.03125L);
87 { /* Negative finite number. */
88 x = -20.085536923187667742L;
89 y = ldexpl (x, 0); ASSERT (y == x);
90 y = ldexpl (x, 5); ASSERT (y == x * 32.0L);
91 y = ldexpl (x, -5); ASSERT (y == x * 0.03125L);
94 for (i = 1, x = 1.73205L; i <= LDBL_MAX_EXP; i++, x *= 2.0L)
96 y = ldexpl (x, 0); ASSERT (y == x);
97 y = ldexpl (x, 5); ASSERT (y == x * 32.0L);
98 y = ldexpl (x, -5); ASSERT (y == x * 0.03125L);
100 for (i = 1, x = 1.73205L; i >= LDBL_MIN_EXP; i--, x *= 0.5L)
102 y = ldexpl (x, 0); ASSERT (y == x);
103 y = ldexpl (x, 5); ASSERT (y == x * 32.0L);
104 if (i - 5 >= LDBL_MIN_EXP)
106 y = ldexpl (x, -5); ASSERT (y == x * 0.03125L);
109 for (; i >= LDBL_MIN_EXP - 100 && x > 0.0L; i--, x *= 0.5L)
111 y = ldexpl (x, 0); ASSERT (y == x);
112 y = ldexpl (x, 5); ASSERT (y == x * 32.0L);