maint: update copyright
[gnulib.git] / tests / nan.h
1 /* Macros for not-a-number.
2    Copyright (C) 2007-2014 Free Software Foundation, Inc.
3
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.
8
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.
13
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/>.  */
16
17
18 /* NaNf () returns a 'float' not-a-number.  */
19
20 /* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler choke
21    on the expression 0.0 / 0.0.  */
22 #if defined __DECC || defined _MSC_VER
23 static float
24 NaNf ()
25 {
26   static float zero = 0.0f;
27   return zero / zero;
28 }
29 #else
30 # define NaNf() (0.0f / 0.0f)
31 #endif
32
33
34 /* NaNd () returns a 'double' not-a-number.  */
35
36 /* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler choke
37    on the expression 0.0 / 0.0.  */
38 #if defined __DECC || defined _MSC_VER
39 static double
40 NaNd ()
41 {
42   static double zero = 0.0;
43   return zero / zero;
44 }
45 #else
46 # define NaNd() (0.0 / 0.0)
47 #endif
48
49
50 /* NaNl () returns a 'long double' not-a-number.  */
51
52 /* On Irix 6.5, gcc 3.4.3 can't compute compile-time NaN, and needs the
53    runtime type conversion.
54    The Microsoft MSVC 9 compiler chokes on the expression 0.0L / 0.0L.  */
55 #ifdef __sgi
56 static long double NaNl ()
57 {
58   double zero = 0.0;
59   return zero / zero;
60 }
61 #elif defined _MSC_VER
62 static long double
63 NaNl ()
64 {
65   static long double zero = 0.0L;
66   return zero / zero;
67 }
68 #else
69 # define NaNl() (0.0L / 0.0L)
70 #endif