1 /* Test setpayloadsigl.
2 Copyright 2024 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 <https://www.gnu.org/licenses/>. */
22 #include "signature.h"
23 SIGNATURE_CHECK (setpayloadsigl
, int, (long double *, long double));
28 #include "isnanl-nolibm.h"
31 #if defined __powerpc__ && LDBL_MANT_DIG == 106
32 /* This is PowerPC "double double", a pair of two doubles. NaN is represented
33 as the corresponding 64-bit IEEE value in the first double; the second is
34 irrelevant and therefore does not contain a payload. */
35 # define PAYLOAD_BITS (DBL_MANT_DIG - 2)
37 # define PAYLOAD_BITS (LDBL_MANT_DIG - 2)
47 /* Test valid payloads. */
48 for (i
= 0, p
= 1.0L; i
< PAYLOAD_BITS
; i
++, p
*= 2.0L)
53 ret
= setpayloadsigl (&x
, p
);
57 /* Test out-of-range payload. */
61 ret
= setpayloadsigl (&x
, p
);
66 /* Test infinite payload. */
71 ret
= setpayloadsigl (&x
, Infinityl ());
76 /* Test negative payload. */
81 ret
= setpayloadsigl (&x
, -1.0L);
86 /* Test fractional payload. */
91 ret
= setpayloadsigl (&x
, 1.4L);
96 return test_exit_status
;