1 /* Test of signbit() substitute.
2 Copyright (C) 2007-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/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2007. */
23 /* signbit must be a macro. */
25 # error missing declaration
31 #include "minus-zero.h"
33 #include "signed-nan.h"
34 #include "signed-snan.h"
39 long double zerol
= 0.0L;
45 ASSERT (!signbit (3.141f
));
46 ASSERT (!signbit (3.141e30f
));
47 ASSERT (!signbit (3.141e-30f
));
48 ASSERT (signbit (-2.718f
));
49 ASSERT (signbit (-2.718e30f
));
50 ASSERT (signbit (-2.718e-30f
));
52 ASSERT (!signbit (0.0f
));
53 if (1.0f
/ minus_zerof
< 0)
54 ASSERT (signbit (minus_zerof
));
56 ASSERT (!signbit (minus_zerof
));
57 /* Infinite values. */
58 ASSERT (!signbit (Infinityf ()));
59 ASSERT (signbit (- Infinityf ()));
61 ASSERT (!signbit (positive_NaNf ()));
62 ASSERT (signbit (negative_NaNf ()));
65 ASSERT (!signbit (positive_SNaNf ()));
66 ASSERT (signbit (negative_SNaNf ()));
74 ASSERT (!signbit (3.141));
75 ASSERT (!signbit (3.141e30
));
76 ASSERT (!signbit (3.141e-30));
77 ASSERT (signbit (-2.718));
78 ASSERT (signbit (-2.718e30
));
79 ASSERT (signbit (-2.718e-30));
81 ASSERT (!signbit (0.0));
82 if (1.0 / minus_zerod
< 0)
83 ASSERT (signbit (minus_zerod
));
85 ASSERT (!signbit (minus_zerod
));
86 /* Infinite values. */
87 ASSERT (!signbit (Infinityd ()));
88 ASSERT (signbit (- Infinityd ()));
90 ASSERT (!signbit (positive_NaNd ()));
91 ASSERT (signbit (negative_NaNd ()));
94 ASSERT (!signbit (positive_SNaNd ()));
95 ASSERT (signbit (negative_SNaNd ()));
103 ASSERT (!signbit (3.141L));
104 ASSERT (!signbit (3.141e30L
));
105 ASSERT (!signbit (3.141e-30L));
106 ASSERT (signbit (-2.718L));
107 ASSERT (signbit (-2.718e30L
));
108 ASSERT (signbit (-2.718e-30L));
110 ASSERT (!signbit (0.0L));
111 if (1.0L / minus_zerol
< 0)
112 ASSERT (signbit (minus_zerol
));
114 ASSERT (!signbit (minus_zerol
));
115 /* Infinite values. */
116 ASSERT (!signbit (Infinityl ()));
117 ASSERT (signbit (- Infinityl ()));
119 ASSERT (!signbit (positive_NaNl ()));
120 ASSERT (signbit (negative_NaNl ()));
122 /* Signalling NaN. */
123 ASSERT (!signbit (positive_SNaNl ()));
124 ASSERT (signbit (negative_SNaNl ()));
134 return test_exit_status
;