Main Page Modules

# Special Quantifies.

Functions to detect and fabricate special quantities in floating-point numbers. More...

## Functions

TRIO_PUBLIC_NAN int | trio_isnan (double number)
| Check for NaN.
TRIO_PUBLIC_NAN int | trio_isinf (double number)
| Check for infinity.
TRIO_PUBLIC_NAN int | trio_isfinite (double number)
| Check for finity.
TRIO_PUBLIC_NAN int | trio_signbit (double number)
| Examine the sign of a number.
TRIO_PUBLIC_NAN int | trio_fpclassify (double number)
| Examine the class of a number.
TRIO_PUBLIC_NAN double | trio_nzero (void)
| Generate negative zero.
TRIO_PUBLIC_NAN double | trio_pinf (void)
| Generate positive infinity.
TRIO_PUBLIC_NAN double | trio_ninf (void)
| Generate negative infinity.
TRIO_PUBLIC_NAN double | trio_nan (void)
| Generate NaN.

## Detailed Description

Functions to detect and fabricate special quantities in floating-point numbers.

SYNOPSIS

    cc ... -ltrio -lm

    #include <trionan.h>

DESCRIPTION

Certain arithmetical operations does not result in normal numbers. Instead they result in special quantities that must be handled differently by the floating-point hardware. These includes Infinity and Not-A-Number (NaN).

For example, 0/0 (zero divided by zero) yields NaN. Any operation which involves a NaN will result in NaN. Any comparison involving NaN will be unsuccessful, even if NaN is compared to NaN.

These special quantities are represented with special bit patterns by the floating-point hardware, and this bit patterns depend on the hardware. There may even be hardware that does not support special quantities, so the functions in this module are not guaranteed to work on all platforms.

The approach used in this module is to (in decreasing order of importance)

- Use C99 functionality when available.
- Use IEEE 754-1985 bit patterns if possible.
- Use platform-specific techniques.

NOTES

This module does not depend on the rest of trio, and can thus be reused separately. The following files are necessary:

- `triodef.h`
- `trionan.h`
- `trionan.c`

## Function Documentation

TRIO_PUBLIC_NAN int trio_fpclassify | ( | double | number | ) |

Examine the class of a number.

Parameters:

  number | An arbitrary floating-point number.

Returns:
  Enumerable value indicating the class of `number`

TRIO_PUBLIC_NAN int trio_isfinite | ( | double | number | ) |

Check for finity.

Parameters:

  number | An arbitrary floating-point number.

Returns:
  Boolean value indicating whether or not the number is a finite.

TRIO_PUBLIC_NAN int trio_isinf | ( | double | number | ) |

Check for infinity.

Parameters:

  number | An arbitrary floating-point number.

Returns:
  1 if positive infinity, -1 if negative infinity, 0 otherwise.

TRIO_PUBLIC_NAN int trio_isnan | ( | double | number | ) |

Check for NaN.

Parameters:

  number | An arbitrary floating-point number.

Returns:
  Boolean value indicating whether or not the number is a NaN.

TRIO_PUBLIC_NAN double trio_nan | ( | void |  | ) |

Generate NaN.

Returns:
  Floating-point representation of NaN.

TRIO_PUBLIC_NAN double trio_ninf | ( | void |  | ) |

Generate negative infinity.

Returns:
  Floating-point value of negative infinity.

TRIO_PUBLIC_NAN double trio_nzero | ( | void |  | ) |

Generate negative zero.

Returns:
  Floating-point representation of negative zero.

TRIO_PUBLIC_NAN double trio_pinf | ( | void |  | ) |

Generate positive infinity.

Returns:
  Floating-point representation of positive infinity.

TRIO_PUBLIC_NAN int trio_signbit | ( | double | number | ) |

Examine the sign of a number.

Parameters:

  number | An arbitrary floating-point number.

Returns:
  Boolean value indicating whether or not the number has the sign bit set (i.e. is negative).

Copyright (C) 2001 - 2006 Bjørn Reese and Daniel Stenberg.