macro/function
<cmath> <ctgmath>
fpclassify functionint fpclassify (float x);int fpclassify (double x);int fpclassify (long double x);
Classify floating-point value
Returns a value of typeint
that matches one of the classification macro constants, depending on the value of x:
value description FP_INFINITE Positive or negative infinity (overflow) FP_NAN Not-A-Number FP_ZERO Value of zero FP_SUBNORMAL Sub-normal value (underflow) FP_NORMAL Normal value (none of the above) Note that each value pertains to a single category: zero is not a normal value.
These macro constants of type int
are defined in header <cmath> (<math.h>).
In C, this is implemented as a macro, but the type of x shall be float
, double
or long double
.
int
values: FP_INFINITE, FP_NAN, FP_ZERO, FP_SUBNORMAL or FP_NORMAL.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* fpclassify example */
#include <stdio.h> /* printf */
#include <math.h> /* fpclassify, signbit, FP_* */
int main()
{
double d = 1.0 / 0.0;
switch (fpclassify(d)) {
case FP_INFINITE: printf ("infinite"); break;
case FP_NAN: printf ("NaN"); break;
case FP_ZERO: printf ("zero"); break;
case FP_SUBNORMAL: printf ("subnormal"); break;
case FP_NORMAL: printf ("normal"); break;
}
if (signbit(d)) printf (" negative\n");
else printf (" positive or unsigned\n");
return 0;
}
infinite positive or unsigned
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4