 |
Cx51 User's Guide |
 |
|
|
|
|
_chkfloat_
| Summary |
|
| Description |
The _chkfloat_ function checks the status of the
floating-point number val.
|
| Return Value |
The _chkfloat_ function returns the status of the
floating-point number val:
| Return Value |
Meaning |
| 0 |
Standard floating-point number. |
| 1 |
Floating-point value 0. |
| 2 |
+INF (positive overflow). |
| 3 |
-INF (negative overflow). |
| 4 |
NaN (Not a Number) error status. |
|
| Example |
#include <intrins.h>
#include <stdio.h> /* for printf */
float f1, f2, f3;
void test_chkfloat (void) {
f1 = f2 * f3;
switch (_chkfloat_ (f1)) {
case 0:
printf ("result is a number\n"); break;
case 1:
printf ("result is zero\n"); break;
case 2:
printf ("result is +INF\n"); break;
case 3:
printf ("result is -INF\n"); break;
case 4:
printf ("result is NaN\n"); break;
}
}
|
Related Knowledgebase Articles
|
|
|