exp2l: Work around a NetBSD 10.0/i386 bug.
[gnulib.git] / lib / signed-nan.h
blob18a550a7515e0b26e1ecda2772fe99d910a13cff
1 /* Macros for quiet not-a-number.
2 Copyright (C) 2023-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 #ifndef _SIGNED_NAN_H
18 #define _SIGNED_NAN_H
20 #include <math.h>
22 #include "nan.h"
25 /* Returns a quiet 'float' NaN with sign bit == 0. */
26 _GL_UNUSED static float
27 positive_NaNf ()
29 /* 'volatile' works around a GCC bug:
30 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111655> */
31 float volatile nan = NaNf ();
32 return (signbit (nan) ? - nan : nan);
35 /* Returns a quiet 'float' NaN with sign bit == 1. */
36 _GL_UNUSED static float
37 negative_NaNf ()
39 /* 'volatile' works around a GCC bug:
40 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111655> */
41 float volatile nan = NaNf ();
42 return (signbit (nan) ? nan : - nan);
46 /* Returns a quiet 'double' NaN with sign bit == 0. */
47 _GL_UNUSED static double
48 positive_NaNd ()
50 /* 'volatile' works around a GCC bug:
51 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111655> */
52 double volatile nan = NaNd ();
53 return (signbit (nan) ? - nan : nan);
56 /* Returns a quiet 'double' NaN with sign bit == 1. */
57 _GL_UNUSED static double
58 negative_NaNd ()
60 /* 'volatile' works around a GCC bug:
61 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111655> */
62 double volatile nan = NaNd ();
63 return (signbit (nan) ? nan : - nan);
67 /* Returns a quiet 'long double' NaN with sign bit == 0. */
68 _GL_UNUSED static long double
69 positive_NaNl ()
71 /* 'volatile' works around a GCC bug:
72 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111655> */
73 long double volatile nan = NaNl ();
74 return (signbit (nan) ? - nan : nan);
77 /* Returns a quiet 'long double' NaN with sign bit == 1. */
78 _GL_UNUSED static long double
79 negative_NaNl ()
81 /* 'volatile' works around a GCC bug:
82 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111655> */
83 long double volatile nan = NaNl ();
84 return (signbit (nan) ? nan : - nan);
88 #endif /* _SIGNED_NAN_H */