1/* Test lround.
2   Copyright (C) 1997-2022 Free Software Foundation, Inc.
3   This file is part of the GNU C Library.
4
5   The GNU C Library is free software; you can redistribute it and/or
6   modify it under the terms of the GNU Lesser General Public
7   License as published by the Free Software Foundation; either
8   version 2.1 of the License, or (at your option) any later version.
9
10   The GNU C Library is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   Lesser General Public License for more details.
14
15   You should have received a copy of the GNU Lesser General Public
16   License along with the GNU C Library; if not, see
17   <https://www.gnu.org/licenses/>.  */
18
19#include "libm-test-driver.c"
20
21static const struct test_f_l_data lround_test_data[] =
22  {
23    /* Bug 6797: errno setting may be missing.  */
24    TEST_f_l (lround, plus_infty, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
25    TEST_f_l (lround, minus_infty, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
26    TEST_f_l (lround, qnan_value, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
27    TEST_f_l (lround, -qnan_value, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
28    TEST_f_l (lround, snan_value, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
29    TEST_f_l (lround, -snan_value, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
30    TEST_f_l (lround, max_value, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
31    TEST_f_l (lround, -max_value, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
32#if LONG_MAX > 0x7fffffff
33    TEST_f_l (lround, 0x1p31, 0x80000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
34    TEST_f_l (lround, 0x1p32, 0x100000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
35    TEST_f_l (lround, 0x1p33, 0x200000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
36#else
37    TEST_f_l (lround, 0x1p31, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
38    TEST_f_l (lround, 0x1p32, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
39    TEST_f_l (lround, 0x1p33, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
40#endif
41    TEST_f_l (lround, 0x1p63, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
42    TEST_f_l (lround, 0x1p64, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
43    TEST_f_l (lround, 0x1p65, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
44    TEST_f_l (lround, -0x1p31, -0x80000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
45#if LONG_MAX > 0x7fffffff
46    TEST_f_l (lround, -0x1p32, -0x100000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
47    TEST_f_l (lround, -0x1p33, -0x200000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
48    TEST_f_l (lround, -0x1p63, LLONG_MIN, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
49#else
50    TEST_f_l (lround, -0x1p32, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
51    TEST_f_l (lround, -0x1p33, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
52    TEST_f_l (lround, -0x1p63, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
53#endif
54    TEST_f_l (lround, -0x1p64, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
55    TEST_f_l (lround, -0x1p65, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
56    TEST_f_l (lround, 0x7fffff80p0, 0x7fffff80LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
57#if !TEST_COND_binary32
58    TEST_f_l (lround, 0x7fffffffp0, 0x7fffffffLL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
59    TEST_f_l (lround, 0x7fffffff.4p0, 0x7fffffffLL, ERRNO_UNCHANGED),
60    TEST_f_l (lround, 0x7fffffff.7ffffcp0, 0x7fffffffLL, ERRNO_UNCHANGED),
61# if LONG_MAX > 0x7fffffff
62    TEST_f_l (lround, 0x7fffffff.8p0, 0x80000000LL, ERRNO_UNCHANGED),
63    TEST_f_l (lround, 0x7fffffff.cp0, 0x80000000LL, ERRNO_UNCHANGED),
64# else
65    TEST_f_l (lround, 0x7fffffff.8p0, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
66    TEST_f_l (lround, 0x7fffffff.cp0, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
67# endif
68#endif
69#if MANT_DIG >= 64
70    TEST_f_l (lround, 0x7fffffff.7fffffff8p0L, 0x7fffffffLL, ERRNO_UNCHANGED),
71#endif
72#if MANT_DIG >= 106
73    TEST_f_l (lround, 0x7fffffff.7fffffffffffffffffep0L, 0x7fffffffLL, ERRNO_UNCHANGED),
74#endif
75#if MANT_DIG >= 113
76    TEST_f_l (lround, 0x7fffffff.7fffffffffffffffffffcp0L, 0x7fffffffLL, ERRNO_UNCHANGED),
77#endif
78#if !TEST_COND_binary32
79    TEST_f_l (lround, -0x80000000.4p0, -0x80000000LL, ERRNO_UNCHANGED),
80    TEST_f_l (lround, -0x80000000.7ffff8p0, -0x80000000LL, ERRNO_UNCHANGED),
81# if LONG_MAX > 0x7fffffff
82    TEST_f_l (lround, -0x80000000.8p0, -0x80000001LL, ERRNO_UNCHANGED),
83    TEST_f_l (lround, -0x80000000.cp0, -0x80000001LL, ERRNO_UNCHANGED),
84    TEST_f_l (lround, -0x80000001p0, -0x80000001LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
85# else
86    TEST_f_l (lround, -0x80000000.8p0, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
87    TEST_f_l (lround, -0x80000000.cp0, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
88    TEST_f_l (lround, -0x80000001p0, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
89# endif
90#endif
91#if LONG_MAX > 0x7fffffff
92    TEST_f_l (lround, -0x80000100p0, -0x80000100LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
93#else
94    TEST_f_l (lround, -0x80000100p0, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
95#endif
96#if MANT_DIG >= 64
97    TEST_f_l (lround, -0x80000000.7fffffffp0L, -0x80000000LL, ERRNO_UNCHANGED),
98#endif
99#if MANT_DIG >= 106
100    TEST_f_l (lround, -0x80000000.7fffffffffffffffffcp0L, -0x80000000LL, ERRNO_UNCHANGED),
101#endif
102#if MANT_DIG >= 113
103    TEST_f_l (lround, -0x80000000.7fffffffffffffffffff8p0L, -0x80000000LL, ERRNO_UNCHANGED),
104#endif
105#if LONG_MAX > 0x7fffffff
106    TEST_f_l (lround, 0x7fffff8000000000p0, 0x7fffff8000000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
107#else
108    TEST_f_l (lround, 0x7fffff8000000000p0, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
109#endif
110#if !TEST_COND_binary32
111# if LONG_MAX > 0x7fffffff
112    TEST_f_l (lround, 0x7ffffffffffffc00p0, 0x7ffffffffffffc00LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
113# else
114    TEST_f_l (lround, 0x7ffffffffffffc00p0, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
115# endif
116#endif
117#if MANT_DIG >= 64
118# if LONG_MAX > 0x7fffffff
119    TEST_f_l (lround, 0x7fffffffffffffffp0L, 0x7fffffffffffffffLL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
120# else
121    TEST_f_l (lround, 0x7fffffffffffffffp0L, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
122# endif
123    TEST_f_l (lround, 0x7fffffffffffffff.8p0L, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
124# if MANT_DIG > 64
125#  if LONG_MAX > 0x7fffffff
126    TEST_f_l (lround, 0x7fffffffffffffff.4p0L, 0x7fffffffffffffffLL, ERRNO_UNCHANGED),
127#  else
128    TEST_f_l (lround, 0x7fffffffffffffff.4p0L, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
129#  endif
130    TEST_f_l (lround, 0x7fffffffffffffff.cp0L, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
131# endif
132# if LONG_MAX > 0x7fffffff
133#  if MANT_DIG >= 106
134    TEST_f_l (lround, 0x7fffffffffffffff.7fffffffffep0L, 0x7fffffffffffffffLL, ERRNO_UNCHANGED),
135#  endif
136#  if MANT_DIG >= 113
137    TEST_f_l (lround, 0x7fffffffffffffff.7fffffffffffcp0L, 0x7fffffffffffffffLL, ERRNO_UNCHANGED),
138#  endif
139# else
140#  if MANT_DIG >= 106
141    TEST_f_l (lround, 0x7fffffffffffffff.7fffffffffep0L, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
142#  endif
143#  if MANT_DIG >= 113
144    TEST_f_l (lround, 0x7fffffffffffffff.7fffffffffffcp0L, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
145#  endif
146# endif
147#endif
148#if MANT_DIG >= 64
149    TEST_f_l (lround, -0x8000000000000001p0L, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
150#endif
151#if MANT_DIG >= 106
152# if LONG_MAX > 0x7fffffff
153    TEST_f_l (lround, -0x8000000000000000.4p0L, LLONG_MIN, ERRNO_UNCHANGED),
154    TEST_f_l (lround, -0x8000000000000000.7fffffffffcp0L, LLONG_MIN, ERRNO_UNCHANGED),
155# else
156    TEST_f_l (lround, -0x8000000000000000.4p0L, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
157    TEST_f_l (lround, -0x8000000000000000.7fffffffffcp0L, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
158# endif
159    TEST_f_l (lround, -0x8000000000000000.8p0L, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
160    TEST_f_l (lround, -0x8000000000000000.cp0L, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
161#endif
162    TEST_f_l (lround, -0x8000010000000000p0, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
163#if !TEST_COND_binary32
164    TEST_f_l (lround, -0x8000000000000800p0, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
165#endif
166#if MANT_DIG >= 113
167# if LONG_MAX > 0x7fffffff
168    TEST_f_l (lround, -0x8000000000000000.7fffffffffff8p0L, LLONG_MIN, ERRNO_UNCHANGED),
169# else
170    TEST_f_l (lround, -0x8000000000000000.7fffffffffff8p0L, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
171# endif
172#endif
173    TEST_f_l (lround, 0, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
174    TEST_f_l (lround, minus_zero, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
175    TEST_f_l (lround, min_value, 0.0, ERRNO_UNCHANGED),
176    TEST_f_l (lround, -min_value, 0, ERRNO_UNCHANGED),
177    TEST_f_l (lround, min_subnorm_value, 0.0, ERRNO_UNCHANGED),
178    TEST_f_l (lround, -min_subnorm_value, 0, ERRNO_UNCHANGED),
179    TEST_f_l (lround, 0.2L, 0.0, ERRNO_UNCHANGED),
180    TEST_f_l (lround, -0.2L, 0, ERRNO_UNCHANGED),
181    TEST_f_l (lround, 0.5, 1, ERRNO_UNCHANGED),
182    TEST_f_l (lround, -0.5, -1, ERRNO_UNCHANGED),
183    TEST_f_l (lround, 0.8L, 1, ERRNO_UNCHANGED),
184    TEST_f_l (lround, -0.8L, -1, ERRNO_UNCHANGED),
185    TEST_f_l (lround, 1.5, 2, ERRNO_UNCHANGED),
186    TEST_f_l (lround, -1.5, -2, ERRNO_UNCHANGED),
187    TEST_f_l (lround, 22514.5, 22515, ERRNO_UNCHANGED),
188    TEST_f_l (lround, -22514.5, -22515, ERRNO_UNCHANGED),
189    TEST_f_l (lround, 1071930.0008, 1071930, ERRNO_UNCHANGED),
190    TEST_f_l (lround, 2097152.5, 2097153, ERRNO_UNCHANGED),
191    TEST_f_l (lround, -2097152.5, -2097153, ERRNO_UNCHANGED),
192#if !TEST_COND_binary32
193    TEST_f_l (lround, 1073741824.01, 1073741824, ERRNO_UNCHANGED),
194# if LONG_MAX > 0x7fffffff
195    TEST_f_l (lround, 34359738368.5, 34359738369ll, ERRNO_UNCHANGED),
196    TEST_f_l (lround, -34359738368.5, -34359738369ll, ERRNO_UNCHANGED),
197    TEST_f_l (lround, -3.65309740835E17, -365309740835000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
198    TEST_f_l (lround, 281474976710656.025, 281474976710656, ERRNO_UNCHANGED),
199    TEST_f_l (lround, 18014398509481974, 18014398509481974, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
200# endif
201#endif
202
203    /* Test boundary conditions.  */
204    /* 0x1FFFFF */
205    TEST_f_l (lround, 2097151.0, 2097151LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
206    /* 0x800000 */
207    TEST_f_l (lround, 8388608.0, 8388608LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
208    /* 0x1000000 */
209    TEST_f_l (lround, 16777216.0, 16777216LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
210#if LONG_MAX > 0x7fffffff
211    /* 0x20000000000 */
212    TEST_f_l (lround, 2199023255552.0, 2199023255552LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
213    /* 0x40000000000 */
214    TEST_f_l (lround, 4398046511104.0, 4398046511104LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
215    /* 0x1000000000000 */
216    TEST_f_l (lround, 281474976710656.0, 281474976710656LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
217    /* 0x10000000000000 */
218    TEST_f_l (lround, 4503599627370496.0, 4503599627370496LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
219    /* 0x10000080000000 */
220    TEST_f_l (lround, 4503601774854144.0, 4503601774854144LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
221    /* 0x20000000000000 */
222    TEST_f_l (lround, 9007199254740992.0, 9007199254740992LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
223    /* 0x80000000000000 */
224    TEST_f_l (lround, 36028797018963968.0, 36028797018963968LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
225    /* 0x100000000000000 */
226    TEST_f_l (lround, 72057594037927936.0, 72057594037927936LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
227#endif
228
229#if !TEST_COND_binary32
230# if LONG_MAX > 0x7fffffff
231    /* 0x100000000 */
232    TEST_f_l (lround, 4294967295.5, 4294967296LL, ERRNO_UNCHANGED),
233    /* 0x200000000 */
234    TEST_f_l (lround, 8589934591.5, 8589934592LL, ERRNO_UNCHANGED),
235# endif
236
237    /* nextafter(0.5,-1)  */
238    TEST_f_l (lround, 0x1.fffffffffffffp-2, 0, ERRNO_UNCHANGED),
239    /* nextafter(-0.5,1)  */
240    TEST_f_l (lround, -0x1.fffffffffffffp-2, 0, ERRNO_UNCHANGED),
241# if LONG_MAX > 0x7fffffff
242    /* On PowerPC an exponent of '52' is the largest incrementally
243     * representable sequence of whole-numbers in the 'double' range.  We test
244     * lround to make sure that a guard bit set during the lround operation
245     * hasn't forced an erroneous shift giving us an incorrect result.  The odd
246     * numbers between +-(2^52+1 and 2^53-1) are affected since they have the
247     * rightmost bit set.  */
248    /* +-(2^52+1)  */
249    TEST_f_l (lround, 0x1.0000000000001p+52, 4503599627370497LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
250    TEST_f_l (lround, -0x1.0000000000001p+52, -4503599627370497LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
251    /* +-(2^53-1): Input is the last (positive and negative) incrementally
252     * representable whole-number in the 'double' range that might round
253     * erroneously.  */
254    TEST_f_l (lround, 0x1.fffffffffffffp+52, 9007199254740991LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
255    TEST_f_l (lround, -0x1.fffffffffffffp+52, -9007199254740991LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
256# endif
257#endif
258    TEST_f_l (lround, 0x1.fffffp-2, 0, ERRNO_UNCHANGED),
259    /* nextafter(0.5,-1)  */
260    TEST_f_l (lround, 0x1.fffffep-2, 0, ERRNO_UNCHANGED),
261    TEST_f_l (lround, -0x1.fffffp-2, 0, ERRNO_UNCHANGED),
262    /* nextafter(-0.5,1)  */
263    TEST_f_l (lround, -0x1.fffffep-2, 0, ERRNO_UNCHANGED),
264    TEST_f_l (lround, 0x1.fffffep+23, 16777215, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
265    TEST_f_l (lround, -0x1.fffffep+23, -16777215, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
266    /* As above, on PowerPC an exponent of '23' is the largest incrementally
267     * representable sequence of whole-numbers in the 'float' range.
268     * Likewise, numbers between +-(2^23+1 and 2^24-1) are affected.  */
269    TEST_f_l (lround, 0x1.000002p+23, 8388609, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
270    TEST_f_l (lround, -0x1.000002p+23, -8388609, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
271    TEST_f_l (lround, 0x1.fffffep+23, 16777215, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
272    TEST_f_l (lround, -0x1.fffffep+23, -16777215, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
273
274#if LONG_MAX > 0x7fffffff
275# if MANT_DIG >= 64
276    /* The input can only be represented in long double.  */
277    TEST_f_l (lround, 4503599627370495.5L, 4503599627370496LL, ERRNO_UNCHANGED),
278    TEST_f_l (lround, 4503599627370496.25L, 4503599627370496LL, ERRNO_UNCHANGED),
279    TEST_f_l (lround, 4503599627370496.5L, 4503599627370497LL, ERRNO_UNCHANGED),
280    TEST_f_l (lround, 4503599627370496.75L, 4503599627370497LL, ERRNO_UNCHANGED),
281    TEST_f_l (lround, 4503599627370497.5L, 4503599627370498LL, ERRNO_UNCHANGED),
282
283#  if MANT_DIG > 100
284    TEST_f_l (lround, 4503599627370495.4999999999999L, 4503599627370495LL, ERRNO_UNCHANGED),
285    TEST_f_l (lround, 4503599627370496.4999999999999L, 4503599627370496LL, ERRNO_UNCHANGED),
286    TEST_f_l (lround, 4503599627370497.4999999999999L, 4503599627370497LL, ERRNO_UNCHANGED),
287    TEST_f_l (lround, 4503599627370494.5000000000001L, 4503599627370495LL, ERRNO_UNCHANGED),
288    TEST_f_l (lround, 4503599627370495.5000000000001L, 4503599627370496LL, ERRNO_UNCHANGED),
289    TEST_f_l (lround, 4503599627370496.5000000000001L, 4503599627370497LL, ERRNO_UNCHANGED),
290
291    TEST_f_l (lround, -4503599627370495.4999999999999L, -4503599627370495LL, ERRNO_UNCHANGED),
292    TEST_f_l (lround, -4503599627370496.4999999999999L, -4503599627370496LL, ERRNO_UNCHANGED),
293    TEST_f_l (lround, -4503599627370497.4999999999999L, -4503599627370497LL, ERRNO_UNCHANGED),
294    TEST_f_l (lround, -4503599627370494.5000000000001L, -4503599627370495LL, ERRNO_UNCHANGED),
295    TEST_f_l (lround, -4503599627370495.5000000000001L, -4503599627370496LL, ERRNO_UNCHANGED),
296    TEST_f_l (lround, -4503599627370496.5000000000001L, -4503599627370497LL, ERRNO_UNCHANGED),
297#  endif
298
299    TEST_f_l (lround, -4503599627370495.5L, -4503599627370496LL, ERRNO_UNCHANGED),
300    TEST_f_l (lround, -4503599627370496.25L, -4503599627370496LL, ERRNO_UNCHANGED),
301    TEST_f_l (lround, -4503599627370496.5L, -4503599627370497LL, ERRNO_UNCHANGED),
302    TEST_f_l (lround, -4503599627370496.75L, -4503599627370497LL, ERRNO_UNCHANGED),
303    TEST_f_l (lround, -4503599627370497.5L, -4503599627370498LL, ERRNO_UNCHANGED),
304
305    TEST_f_l (lround, 9007199254740991.5L, 9007199254740992LL, ERRNO_UNCHANGED),
306    TEST_f_l (lround, 9007199254740992.25L, 9007199254740992LL, ERRNO_UNCHANGED),
307    TEST_f_l (lround, 9007199254740992.5L, 9007199254740993LL, ERRNO_UNCHANGED),
308    TEST_f_l (lround, 9007199254740992.75L, 9007199254740993LL, ERRNO_UNCHANGED),
309    TEST_f_l (lround, 9007199254740993.5L, 9007199254740994LL, ERRNO_UNCHANGED),
310
311#  if MANT_DIG > 100
312    TEST_f_l (lround, 9007199254740991.4999999999999L, 9007199254740991LL, ERRNO_UNCHANGED),
313    TEST_f_l (lround, 9007199254740992.4999999999999L, 9007199254740992LL, ERRNO_UNCHANGED),
314    TEST_f_l (lround, 9007199254740993.4999999999999L, 9007199254740993LL, ERRNO_UNCHANGED),
315    TEST_f_l (lround, 9007199254740991.5000000000001L, 9007199254740992LL, ERRNO_UNCHANGED),
316    TEST_f_l (lround, 9007199254740992.5000000000001L, 9007199254740993LL, ERRNO_UNCHANGED),
317    TEST_f_l (lround, 9007199254740993.5000000000001L, 9007199254740994LL, ERRNO_UNCHANGED),
318
319    TEST_f_l (lround, -9007199254740991.4999999999999L, -9007199254740991LL, ERRNO_UNCHANGED),
320    TEST_f_l (lround, -9007199254740992.4999999999999L, -9007199254740992LL, ERRNO_UNCHANGED),
321    TEST_f_l (lround, -9007199254740993.4999999999999L, -9007199254740993LL, ERRNO_UNCHANGED),
322    TEST_f_l (lround, -9007199254740991.5000000000001L, -9007199254740992LL, ERRNO_UNCHANGED),
323    TEST_f_l (lround, -9007199254740992.5000000000001L, -9007199254740993LL, ERRNO_UNCHANGED),
324    TEST_f_l (lround, -9007199254740993.5000000000001L, -9007199254740994LL, ERRNO_UNCHANGED),
325#  endif
326
327    TEST_f_l (lround, -9007199254740991.5L, -9007199254740992LL, ERRNO_UNCHANGED),
328    TEST_f_l (lround, -9007199254740992.25L, -9007199254740992LL, ERRNO_UNCHANGED),
329    TEST_f_l (lround, -9007199254740992.5L, -9007199254740993LL, ERRNO_UNCHANGED),
330    TEST_f_l (lround, -9007199254740992.75L, -9007199254740993LL, ERRNO_UNCHANGED),
331    TEST_f_l (lround, -9007199254740993.5L, -9007199254740994LL, ERRNO_UNCHANGED),
332
333    TEST_f_l (lround, 72057594037927935.5L, 72057594037927936LL, ERRNO_UNCHANGED),
334    TEST_f_l (lround, 72057594037927936.25L, 72057594037927936LL, ERRNO_UNCHANGED),
335    TEST_f_l (lround, 72057594037927936.5L, 72057594037927937LL, ERRNO_UNCHANGED),
336    TEST_f_l (lround, 72057594037927936.75L, 72057594037927937LL, ERRNO_UNCHANGED),
337    TEST_f_l (lround, 72057594037927937.5L, 72057594037927938LL, ERRNO_UNCHANGED),
338
339    TEST_f_l (lround, -72057594037927935.5L, -72057594037927936LL, ERRNO_UNCHANGED),
340    TEST_f_l (lround, -72057594037927936.25L, -72057594037927936LL, ERRNO_UNCHANGED),
341    TEST_f_l (lround, -72057594037927936.5L, -72057594037927937LL, ERRNO_UNCHANGED),
342    TEST_f_l (lround, -72057594037927936.75L, -72057594037927937LL, ERRNO_UNCHANGED),
343    TEST_f_l (lround, -72057594037927937.5L, -72057594037927938LL, ERRNO_UNCHANGED),
344
345    TEST_f_l (lround, 9223372036854775806.25L, 9223372036854775806LL, ERRNO_UNCHANGED),
346    TEST_f_l (lround, -9223372036854775806.25L, -9223372036854775806LL, ERRNO_UNCHANGED),
347    TEST_f_l (lround, 9223372036854775806.5L, 9223372036854775807LL, ERRNO_UNCHANGED),
348    TEST_f_l (lround, -9223372036854775806.5L, -9223372036854775807LL, ERRNO_UNCHANGED),
349    TEST_f_l (lround, 9223372036854775807.0L, 9223372036854775807LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
350    TEST_f_l (lround, -9223372036854775807.0L, -9223372036854775807LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
351# endif
352#endif
353  };
354
355static void
356lround_test (void)
357{
358  ALL_RM_TEST (lround, 1, lround_test_data, RUN_TEST_LOOP_f_l, END);
359}
360
361static void
362do_test (void)
363{
364  lround_test ();
365}
366
367/*
368 * Local Variables:
369 * mode:c
370 * End:
371 */
372