FE_DFL_ENV

< cpp‎ | numeric‎ | fenv

C++
 Sprache Concepts Utilities-Bibliothek Strings Bibliothek Container-Bibliothek Algorithmen-Bibliothek Iteratoren Bibliothek Numerik-Bibliothek Input / Output-Bibliothek Lokalisierungen Bibliothek Reguläre Ausdrücke Bibliothek (C++11) Atomare Operationen Bibliothek (C++11) Thread Support-Bibliothek (C++11)

Numerik-Bibliothek
Gemeinsame mathematischen Funktionen
Floating-Point-Umgebung
Komplexe Zahlen
Numerische Arrays
Pseudo-Zufallszahlen
Compile-time rationale Arithmetik (C++11)
Generische numerische Operationen
Original:
Generic numeric operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 iota (C++11)
 accumulate
 inner_product
 partial_sum

Floating-Point-Umgebung
Funktionen
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 feclearexcept (C++11)
 fetestexcept (C++11)
 feraiseexcept (C++11)
 fegetexceptflagfesetexceptflag (C++11)(C++11)
 fegetroundfesetround (C++11)(C++11)
 fegetenvfesetenv (C++11)
 feholdexcept (C++11)
 feupdateenv (C++11)
Makro Konstanten
Original:
Macro constants
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 FE_ALL_EXCEPTFE_DIVBYZEROFE_INEXACTFE_INVALIDFE_OVERFLOWFE_UNDERFLOW (C++11)
 FE_DOWNWARDFE_TONEARESTFE_TOWARDZEROFE_UPWARD (C++11)
 FE_DFL_ENV (C++11)

 Defined in header #define FE_DFL_ENV  /*implementation defined*/ (seit C++11)
Das Makro konstanten FE_DFL_ENV erweitert, um einen Ausdruck des Typs const std::fenv_t*, was zu einer vollständigen Kopie der Standard-Floating-Point-Umfeld, dh die Umwelt beim Programmstart geladen weist .
Original:
The macro constant FE_DFL_ENV expands to an expression of type const std::fenv_t*, which points to a full copy of the default floating-point environment, that is, the environment as loaded at program startup.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Zusätzliche Makros, die mit `FE_` beginnen, gefolgt von Großbuchstaben, und haben die Art const std::fenv_t*, kann durch eine Implementierung unterstützt werden .
Original:
Additional macros that begin with `FE_` followed by uppercase letters, and have the type const std::fenv_t*, may be supported by an implementation.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[Bearbeiten]Beispiel

```#include <iostream>
#include <cfenv>

#pragma STDC FENV_ACCESS ON

void show_env()
{
int e = std::fetestexcept(FE_ALL_EXCEPT);
if(e & FE_DIVBYZERO) std::cout << "division by zero is raised\n";
if(e & FE_INEXACT)   std::cout << "inexact is raised\n";
if(e & FE_INVALID)   std::cout << "invalid is raised\n";
if(e & FE_UNDERFLOW) std::cout << "underflow is raised\n";
if(e & FE_OVERFLOW)  std::cout << "overflow is raised\n";
int r = std::fegetround();
switch(r)
{
case FE_DOWNWARD: std::cout << "rounding down\n"; break;
case FE_TONEAREST: std::cout << "rounding to nearest\n"; break;
case FE_TOWARDZERO: std::cout << "rounding to zero\n"; break;
case FE_UPWARD: std::cout << "rounding up\n"; break;
}
}

int main()
{
std::cout << "On startup: \n";
show_env();

std::feraiseexcept(FE_UNDERFLOW | FE_OVERFLOW);
std::fesetround(FE_UPWARD);

std::cout << "\nBefore restoration: \n";
show_env();

std::fesetenv(FE_DFL_ENV);

std::cout << "\nAfter reset to default: \n";
show_env();
}```

Output:

```On startup:
rounding to nearest

Before restoration:
underflow is raised
overflow is raised
rounding up

After reset to default:
rounding to nearest```

[Bearbeiten]Siehe auch

 fegetenvfesetenv(C++11) speichert oder stellt die aktuelle Floating-Point-UmgebungOriginal: saves or restores the current floating point environmentThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (Funktion)  feupdateenv(C++11) stellt die Floating-Point-Umgebung und stellt die zuvor Ausnahmen auslösenOriginal: restores the floating-point environment and raises the previously raise exceptionsThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (Funktion)