Functions to detect and fabricate special quantities in floating-point numbers. More...
Functions | |
TRIO_PUBLIC_NAN int | trio_isnan (double number) |
Check for NaN. More... | |
TRIO_PUBLIC_NAN int | trio_isinf (double number) |
Check for infinity. More... | |
TRIO_PUBLIC_NAN int | trio_isfinite (double number) |
Check for finity. More... | |
TRIO_PUBLIC_NAN int | trio_signbit (double number) |
Examine the sign of a number. More... | |
TRIO_PUBLIC_NAN int | trio_fpclassify (double number) |
Examine the class of a number. More... | |
TRIO_PUBLIC_NAN double | trio_nzero (void) |
Generate negative zero. More... | |
TRIO_PUBLIC_NAN double | trio_pinf (void) |
Generate positive infinity. More... | |
TRIO_PUBLIC_NAN double | trio_ninf (void) |
Generate negative infinity. More... | |
TRIO_PUBLIC_NAN double | trio_nan (void) |
Generate NaN. More... | |
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)
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
TRIO_PUBLIC_NAN int trio_fpclassify | ( | double | number | ) |
Examine the class of a number.
number | An arbitrary floating-point number. |
number
TRIO_PUBLIC_NAN int trio_isfinite | ( | double | number | ) |
Check for finity.
number | An arbitrary floating-point number. |
TRIO_PUBLIC_NAN int trio_isinf | ( | double | number | ) |
Check for infinity.
number | An arbitrary floating-point number. |
TRIO_PUBLIC_NAN int trio_isnan | ( | double | number | ) |
Check for NaN.
number | An arbitrary floating-point number. |
TRIO_PUBLIC_NAN double trio_nan | ( | void | ) |
TRIO_PUBLIC_NAN double trio_ninf | ( | void | ) |
Generate negative infinity.
References trio_pinf().
TRIO_PUBLIC_NAN double trio_nzero | ( | void | ) |
Generate negative zero.
TRIO_PUBLIC_NAN double trio_pinf | ( | void | ) |
Generate positive infinity.
Referenced by trio_nan(), and trio_ninf().
TRIO_PUBLIC_NAN int trio_signbit | ( | double | number | ) |
Examine the sign of a number.
number | An arbitrary floating-point number. |