std:: fpclassify
| Common mathematical functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Mathematical special functions (C++17) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Mathematical constants (C++20) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Basic linear algebra algorithms (C++26) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Data-parallel types (SIMD) (C++26) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Floating-point environment (C++11) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Complex numbers | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Numeric array (
valarray
)
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Pseudo-random number generation | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Bit manipulation (C++20) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Saturation arithmetic (C++26) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Factor operations | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Interpolations | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Generic numeric operations | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| C-style checked integer arithmetic | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Nearest integer floating point operations | |||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Floating point manipulation functions | |||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Classification and comparison | |||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||
| Types | |||||||||||||||||||||||||||||||||||||||||
| Macro constants | |||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
|
Definiert im Header
<cmath>
|
||
| (1) | ||
|
int
fpclassify
(
float
num
)
;
int
fpclassify
(
double
num
)
;
|
(seit C++11)
(bis C++23) |
|
|
constexpr
int
fpclassify
(
/* floating-point-type */
num
)
;
|
(seit C++23) | |
|
Definiert im Header
<cmath>
|
||
|
template
<
class
Integer
>
int fpclassify ( Integer num ) ; |
(A) |
(seit C++11)
(constexpr seit C++23) |
std::fpclassify
für alle cv-unqualifizierten Gleitkommatypen als Typ des Parameters
num
an.
(seit C++23)
Inhaltsverzeichnis |
Parameter
| num | - | Gleitkomma- oder Ganzzahlwert |
Rückgabewert
einer von FP_INFINITE , FP_NAN , FP_NORMAL , FP_SUBNORMAL , FP_ZERO oder ein implementierungsdefinierter Typ, der die Kategorie von num spezifiziert.
Hinweise
Die zusätzlichen Überladungen müssen nicht exakt wie (A) bereitgestellt werden. Sie müssen lediglich sicherstellen, dass für ihr Argument num vom Ganzzahltyp std :: fpclassify ( num ) dieselbe Wirkung hat wie std :: fpclassify ( static_cast < double > ( num ) ) .
Beispiel
#include <cfloat> #include <cmath> #include <iostream> auto show_classification(double x) { switch (std::fpclassify(x)) { case FP_INFINITE: return "Inf"; case FP_NAN: return "NaN"; case FP_NORMAL: return "normal"; case FP_SUBNORMAL: return "subnormal"; case FP_ZERO: return "zero"; default: return "unknown"; } } int main() { std::cout << "1.0/0.0 is " << show_classification(1 / 0.0) << '\n' << "0.0/0.0 is " << show_classification(0.0 / 0.0) << '\n' << "DBL_MIN/2 is " << show_classification(DBL_MIN / 2) << '\n' << "-0.0 is " << show_classification(-0.0) << '\n' << "1.0 is " << show_classification(1.0) << '\n'; }
Ausgabe:
1.0/0.0 is Inf 0.0/0.0 is NaN DBL_MIN/2 is subnormal -0.0 is zero 1.0 is normal
Siehe auch
|
(C++11)
|
prüft, ob die gegebene Zahl einen endlichen Wert hat
(Funktion) |
|
(C++11)
|
prüft, ob die gegebene Zahl unendlich ist
(Funktion) |
|
(C++11)
|
prüft, ob die gegebene Zahl NaN ist
(Funktion) |
|
(C++11)
|
prüft, ob die gegebene Zahl normal ist
(Funktion) |
|
bietet eine Schnittstelle zur Abfrage von Eigenschaften aller grundlegenden numerischen Typen
(Klassentemplate) |
|
|
C-Dokumentation
für
fpclassify
|
|