glob: Declare variables at the very start of their scope.
[gnulib/ericb.git] / tests / infinity.h
blobef5d3bd71e11529bf5d6439ea28bc8723bd0cbc1
1 /* Macros for infinity.
2 Copyright (C) 2011-2017 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 <http://www.gnu.org/licenses/>. */
18 /* Infinityf () returns a 'float' +Infinity. */
20 /* The Microsoft MSVC 9 compiler chokes on the expression 1.0f / 0.0f.
21 The IBM XL C compiler on z/OS complains.
22 PGI 16.10 complains. */
23 #if defined _MSC_VER || (defined __MVS__ && defined __IBMC__) || defined __PGI
24 static float
25 Infinityf ()
27 static float zero = 0.0f;
28 return 1.0f / zero;
30 #else
31 # define Infinityf() (1.0f / 0.0f)
32 #endif
35 /* Infinityd () returns a 'double' +Infinity. */
37 /* The Microsoft MSVC 9 compiler chokes on the expression 1.0 / 0.0.
38 The IBM XL C compiler on z/OS complains.
39 PGI 16.10 complains. */
40 #if defined _MSC_VER || (defined __MVS__ && defined __IBMC__) || defined __PGI
41 static double
42 Infinityd ()
44 static double zero = 0.0;
45 return 1.0 / zero;
47 #else
48 # define Infinityd() (1.0 / 0.0)
49 #endif
52 /* Infinityl () returns a 'long double' +Infinity. */
54 /* The Microsoft MSVC 9 compiler chokes on the expression 1.0L / 0.0L.
55 The IBM XL C compiler on z/OS complains.
56 PGI 16.10 complains. */
57 #if defined _MSC_VER || (defined __MVS__ && defined __IBMC__) || defined __PGI
58 static long double
59 Infinityl ()
61 static long double zero = 0.0L;
62 return 1.0L / zero;
64 #else
65 # define Infinityl() (1.0L / 0.0L)
66 #endif