[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Base Operating System and Extensions Technical Reference, Volume 1

## class, _class, finite, isnan, or unordered Subroutines

### Purpose

Determines classifications of floating-point numbers.

### Libraries

IEEE Math Library (libm.a)
or System V Math Library (libmsaa.a)

### Syntax

```#include <math.h>
#include <float.h>```
```int
class(x)
double x;```
```#include <math.h>
#include <float.h>```
```int
_class(x)
double x;```
`#include <math.h>`
```int finite(x)
double x;```
`#include <math.h>`
```int isnan(x)
double x;```
`#include <math.h>`
```int unordered(x,
y)
double x, y;```

### Description

The class subroutine, _class subroutine, finite subroutine, isnan subroutine, and unordered subroutine determine the classification of their floating-point value. The unordered subroutine determines if a floating-point comparison involving x and y would generate the IEEE floating-point unordered condition (such as whether x or y is a NaN).

The class subroutine returns an integer that represents the classification of the floating-point x parameter. Since class is a reversed key word in C++. The class subroutine can not be invoked in a C++ program. The _class subroutine is an interface for C++ program using the class subroutine. The interface and the return value for class and _class subroutines are identical. The values returned by the class subroutine are defined in the float.h header file. The return values are the following:

 FP_PLUS_NORM Positive normalized, nonzero x FP_MINUS_NORM Negative normalized, nonzero x FP_PLUS_DENORM Positive denormalized, nonzero x FP_MINUS_DENORM Negative denormalized, nonzero x FP_PLUS_ZERO x = +0.0 FP_MINUS_ZERO x = -0.0 FP_PLUS_INF x = +INF FP_MINUS_INF x = -INF FP_NANS x = Signaling Not a Number (NaNS) FP_NANQ x = Quiet Not a Number (NaNQ)

Since class is a reserved keyword in C++, the class subroutine cannot be invoked in a C++ program. The _class subroutine is an interface for the C++ program using the class subroutine. The interface and the return values for class and _class subroutines are identical.

The finite subroutine returns a nonzero value if the x parameter is a finite number; that is, if x is not +-, INF, NaNQ, or NaNS.

The isnan subroutine returns a nonzero value if the x parameter is an NaNS or a NaNQ. Otherwise, it returns 0.

The unordered subroutine returns a nonzero value if a floating-point comparison between x and y would be unordered. Otherwise, it returns 0.

Note: Compile any routine that uses subroutines from the libm.a library with the -lm flag. To compile the class.c file, for example, enter:
`cc class.c -lm`

### Parameters

 x Specifies some double-precision floating-point value. y Specifies some double-precision floating-point value.

### Error Codes

The finite, isnan, and unordered subroutines neither return errors nor set bits in the floating-point exception status, even if a parameter is an NaNS.

### Implementation Specifics

These subroutines are part of Base Operating System (BOS) Runtime.

### Related Information

IEEE Standard for Binary Floating-Point Arithmetic (ANSI/IEEE Standards 754-1985 and 854-1987).

List of Numerical Manipulation Services and Subroutines Overview in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.

[ Previous | Next | Contents | Glossary | Home | Search ]