HPlogo HP-UX Reference Volume 4 of 5 > f

fpclassify(3M)

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

NAME

fpclassify() — floating-point operand classification macro

SYNOPSIS

#include <math.h>

int fpclassify( floating-type x);

DESCRIPTION

The fpclassify() macro classifies its argument value as NaN, infinite, normalized, denormalized, or zero.

The fpclassify() macro can be used with either double or float arguments, and classifies the argument based on its type.

The ISO/ANSI C committee has approved the fpclassify() macro for inclusion in the forthcoming C9X draft standard. The fpclassify() macro implements the class() function recommended by the IEEE-754 standard for floating-point arithmetic.

To use the fpclassify() macro, compile either with the default -Ae option or with the -Aa and -D_HPUX_SOURCE options. Make sure your program includes <math.h>. Link in the math library by specifying -lm on the compiler or linker command line.

The fpclassify() macro, used in conjunction with the signbit() macro, replaces the fpclassify() and fpclassifyf() functions, which are obsolete and are no longer supported.

RETURN VALUE

The fpclassify() macro returns the value of the number classification macro appropriate to the type and value of its argument.

The value returned is one of the following macros, which are defined in <math.h>:

FP_NORMAL Normalized FP_ZERO Zero FP_INFINITE Infinity FP_SUBNORMAL Denormalized FP_NAN NaN

Every possible argument value falls into one of these categories, so these functions never result in an error.

ERRORS

No errors are defined.

EXAMPLE

Take certain actions if x is either a denormalized float value or zero:

#include <math.h> /*...*/ int class; float x; /*...*/ class = fpclassify(x); if ( (class == FP_SUBNORMAL) || (class == FP_ZERO) ) { /*...*/ }

© Hewlett-Packard Development Company, L.P.