2 * floatmagic.h -- Definitions of isnan and isinf for gawk.
6 * Copyright (C) 2009 the Free Software Foundation, Inc.
8 * This file is part of GAWK, the GNU implementation of the
9 * AWK Programming Language.
11 * GAWK is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
16 * GAWK is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
27 * NOTE: <math.h> MUST be included before this file. Also <config.h>.
29 * These definitions are taken from the Autoconf 2.63 manual. Not pretty.
35 (sizeof (x) == sizeof (long double) ? isnan_ld (x) \
36 : sizeof (x) == sizeof (double) ? isnan_d (x) \
38 static inline int isnan_f (float x) { return x != x; }
39 static inline int isnan_d (double x) { return x != x; }
40 static inline int isnan_ld (long double x) { return x != x; }
47 (sizeof (x) == sizeof (long double) ? isinf_ld (x) \
48 : sizeof (x) == sizeof (double) ? isinf_d (x) \
50 static inline int isinf_f (float x) { return isnan (x - x); }
51 static inline int isinf_d (double x) { return isnan (x - x); }
52 static inline int isinf_ld (long double x) { return isnan (x - x); }