FE_DFL_ENV
De cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<tbody> </tbody>| Déclaré dans l'en-tête <cfenv>
|
||
#define FE_DFL_ENV /*implementation defined*/ |
(depuis C++11) | |
Le FE_DFL_ENV macro constante développe en une expression de
const std::fenv_t* type, qui pointe vers une copie complète de la valeur par défaut en virgule flottante environnement, qui est, de l'environnement tel qu'il est chargé au démarrage du programme .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.
You can help to correct and verify the translation. Click here for instructions.
Macros complémentaires qui commencent par
FE_ suivie par des lettres majuscules, et le const std::fenv_t* nature, peuvent être pris en charge par une mise en œuvre .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.
You can help to correct and verify the translation. Click here for instructions.
Exemple
#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();
}
Résultat :
On startup:
rounding to nearest
Before restoration:
underflow is raised
overflow is raised
rounding up
After reset to default:
rounding to nearest
Voir aussi
(C++11) |
sauvegarde ou restaure l'environnement actuel point flottant Original: saves or restores the current floating point environment The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction) |
(C++11) |
restaure l'environnement en virgule flottante et soulève le lever des exceptions précédemment Original: restores the floating-point environment and raises the previously raise exceptions The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction) |