Man Linux: Main Page and Category List

fpclassify, isfinite, isnormal, isnan, isinf - floating-point classification macros

#include<math.h>intfpclassify(x);intisfinite(x);intisnormal(x);intisnan(x);intisinf(x);Link with-lm. Feature Test Macro Requirements for glibc (seefeature_test_macros(7)):fpclassify(),isfinite(),isnormal(): _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE; orcc-std=c99isnan(): _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE || _ISOC99_SOURCE; orcc-std=c99isinf(): _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE; orcc-std=c99

Floating point numbers can have special values, such as infinite or NaN. With the macrofpclassify(x)you can find out what typexis. The macro takes any floating-point expression as argument. The result is one of the following values:FP_NANxis "Not a Number".FP_INFINITExis either positive infinity or negative infinity.FP_ZEROxis zero.FP_SUBNORMALxis too small to be represented in normalized format.FP_NORMALif nothing of the above is correct then it must be a normal floating-point number. The other macros provide a short answer to some standard questions.isfinite(x)returns a nonzero value if (fpclassify(x) != FP_NAN && fpclassify(x) != FP_INFINITE)isnormal(x)returns a nonzero value if (fpclassify(x) == FP_NORMAL)isnan(x)returns a nonzero value if (fpclassify(x) == FP_NAN)isinf(x)returns 1 ifxis positive infinity, and -1 ifxis negative infinity.

C99, POSIX.1. Forisinf(), the standards merely say that the return value is nonzero if and only if the argument has an infinite value.

In glibc 2.01 and earlier,isinf() returns a nonzero value (actually: 1) ifxis positive infinity or negative infinity. (This is all that C99 requires.)

finite(3),INFINITY(3),isgreater(3),signbit(3)

This page is part of release 3.24 of the Linuxman-pagesproject. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. 2008-08-07 FPCLASSIFY(3)