Espaços nominais
Variantes
Ações

FE_DFL_ENV

De cppreference.com

<metanoindex/>

 
 
Biblioteca numéricos
Funções matemáticas comuns
De ponto flutuante ambiente
Números complexos
Matrizes numéricas
Pseudo-aleatório de geração de números
Tempo de compilação aritmética racional (C++11)
Genéricos operações numéricas
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.
(C++11)
 
De ponto flutuante ambiente
Funções
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)(C++11)
Constantes de macros
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.
(C++11)
 
<tbody> </tbody>
Definido no cabeçalho <cfenv>
#define FE_DFL_ENV /*implementation defined*/
(desde C++11)
O FE_DFL_ENV macro constante expande a uma expressão de const std::fenv_t* tipo, que aponta para uma cópia completa do ambiente padrão de ponto flutuante, ou seja, o meio ambiente como carregado na inicialização do programa.
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.
Macros adicionais que começam com FE_ seguido por letras maiúsculas e têm o const std::fenv_t* tipo, pode ser suportado por uma implementação.
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.

Exemplo

#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();
}

Saída:

On startup: 
rounding to nearest

Before restoration: 
underflow is raised
overflow is raised
rounding up

After reset to default: 
rounding to nearest

Veja também

salva ou restaura o ambiente actual ponto flutuante
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.

(função) [edit]
restaura o ambiente de ponto flutuante e levanta a anteriormente levantar exceções
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.

(função) [edit]