std::feraiseexcept
Aus cppreference.com
<metanoindex/>
<tbody> </tbody>| definiert in Header <cfenv>
|
||
int feraiseexcept( int excepts ); |
(seit C++11) | |
Versuche, alle Fließkomma-Ausnahmen in
excepts aufgeführt (eine bitweise OR der Gleitkomma-Ausnahme Makros) zu erhöhen. Wenn eine der Ausnahmen ist FE_OVERFLOW oder FE_UNDERFLOW, kann diese Funktion zusätzlich zu erhöhen FE_INEXACT. Die Reihenfolge, in der die Ausnahmen angehoben ist unbegrenzt, außer dass FE_OVERFLOW und FE_UNDERFLOW werden immer vor FE_INEXACT erhöht .Original:
Attempts to raise all floating point exceptions listed in
excepts (a bitwise OR of the Gleitkomma-Ausnahme Makros). If one of the exceptions is FE_OVERFLOW or FE_UNDERFLOW, this function may additionally raise FE_INEXACT. The order in which the exceptions are raised is unspecified, except that FE_OVERFLOW and FE_UNDERFLOW are always raised before FE_INEXACT.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Parameter
| excepts | - | Bitmaske Auflistung der Ausnahme-Flags zu erheben
Original: bitmask listing the exception flags to raise The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Rückgabewert
0 wenn alle aufgeführten Ausnahmen ausgelöst wurden, nicht den Wert Null sonst .Original:
0 if all listed exceptions were raised, non-zero value otherwise.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Beispiel
#include <iostream>
#include <cfenv>
#pragma STDC FENV_ACCESS ON
int main()
{
std::feclearexcept(FE_ALL_EXCEPT);
int r = std::feraiseexcept(FE_UNDERFLOW | FE_DIVBYZERO);
std::cout << "Raising divbyzero and underflow simultaneously "
<< (r?"fails":"succeeds") << " and results in\n";
int e = std::fetestexcept(FE_ALL_EXCEPT);
if (e & FE_DIVBYZERO) {
std::cout << "division by zero\n";
}
if (e & FE_INEXACT) {
std::cout << "inexact\n";
}
if (e & FE_INVALID) {
std::cout << "invalid\n";
}
if (e & FE_UNDERFLOW) {
std::cout << "underflow\n";
}
if (e & FE_OVERFLOW) {
std::cout << "overflow\n";
}
}
Output:
Raising divbyzero and underflow simultaneously succeeds and results in
division by zero
underflow
