Espacios de nombres
Variantes
Acciones

FE_DIVBYZERO, FE_INEXACT, FE_INVALID, FE_OVERFLOW, FE_UNDERFLOW, FE_ALL_EXCEPT

De cppreference.com
< cpp‎ | numeric‎ | fenv
 
 
 
Entorno de punto flotante
Funciones
(C++11)(C++11)
(C++11)(C++11)
Constantes de macro
FE_ALL_EXCEPTFE_DIVBYZEROFE_INEXACTFE_INVALIDFE_OVERFLOWFE_UNDERFLOW
(C++11)(C++11)(C++11)(C++11)(C++11)(C++11)
(C++11)
 
Definido en el archivo de encabezado <cfenv>
#define FE_DIVBYZERO    /*implementation defined power of 2*/
(desde C++11)
#define FE_INEXACT      /*implementation defined power of 2*/
(desde C++11)
#define FE_INVALID      /*implementation defined power of 2*/
(desde C++11)
#define FE_OVERFLOW     /*implementation defined power of 2*/
(desde C++11)
#define FE_UNDERFLOW    /*implementation defined power of 2*/
(desde C++11)
#define FE_ALL_EXCEPT  FE_DIVBYZERO | FE_INEXACT | \

                       FE_INVALID | FE_OVERFLOW |  \

                       FE_UNDERFLOW
(desde C++11)
Todas estas constantes macro (excepto FE_ALL_EXCEPT) extender a expresiones constantes enteros que son potencias distintas de 2, que identifican de forma única todos apoyados excepciones de punto flotante. Cada macro se define sólo si es respaldada .
Original:
All these macro constants (except FE_ALL_EXCEPT) expand to integer constant expressions that are distinct powers of 2, which uniquely identify all supported floating-point exceptions. Each macro is only defined if it is supported.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
El FE_ALL_EXCEPT macro constante, que se expande a la OR bit a bit de todos FE_* otra parte, siempre se define y es cero si excepciones de punto flotante no son compatibles con la puesta en práctica .
Original:
The macro constant FE_ALL_EXCEPT, which expands to the bitwise OR of all other FE_*, is always defined and is zero if floating-point exceptions are not supported by the implementation.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Constant
Original:
Constant
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Explanation
FE_DIVBYZERO
la división por cero se produjo durante la operación anterior de punto flotante
Original:
division by zero occurred during the earlier floating-point operation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
FE_INEXACT
inexacto resultado: redondeo era necesario para almacenar el resultado de la operación anterior de punto flotante
Original:
inexact result: rounding was necessary to store the result of the earlier floating-point operation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
FE_INVALID
operación no válida: la operación de punto flotante antes no podía realizar
Original:
invalid operation: the earlier floating-point operation could not performed
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
FE_OVERFLOW
el resultado de la anterior operación de punto flotante era demasiado grande para ser representable
Original:
the result of the earlier floating-point operation was too large to be representable
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
FE_UNDERFLOW
el resultado de la operación anterior de punto flotante era subnormal
Original:
the result of the earlier floating-point operation was subnormal
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
FE_ALL_EXCEPT
OR bit a bit de todos los soportados excepciones de punto flotante
Original:
bitwise OR of all supported floating-point exceptions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
La aplicación puede definir constantes adicionales macro en <cfenv> para identificar otras excepciones de punto flotante. Todas las constantes tales comenzar con FE_ seguido por al menos una letra mayúscula .
Original:
The implementation may define additional macro constants in <cfenv> to identify additional floating-point exceptions. All such constants begin with FE_ followed by at least one uppercase letter.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Ejemplo

#include <iostream>
#include <cfenv>
#include <cmath>
 
#pragma STDC FENV_ACCESS ON
 
volatile double zero = 0.0; // volatile not needed where FENV_ACCESS is supported
volatile double one = 1.0;  // volatile not needed where FENV_ACCESS is supported
 
int main()
{
    std::feclearexcept(FE_ALL_EXCEPT);
    std::cout <<  "1.0/0.0 = " << 1.0 / zero << '\n';
    if(std::fetestexcept(FE_DIVBYZERO)) {
        std::cout << "division by zero reported\n";
    } else {
        std::cout << "divsion by zero not reported\n";
    }
 
    std::feclearexcept(FE_ALL_EXCEPT);
    std::cout << "1.0/10 = " << one/10 << '\n';
    if(std::fetestexcept(FE_INEXACT)) {
        std::cout << "inexact result reported\n";
    } else {
        std::cout << "inexact result not reported\n";
    }
 
    std::feclearexcept(FE_ALL_EXCEPT);
    std::cout << "sqrt(-1) = " << std::sqrt(-1) << '\n';
    if(std::fetestexcept(FE_INVALID)) {
        std::cout << "invalid result reported\n";
    } else {
        std::cout << "invalid result not reported\n";
    }
}

Salida:

1.0/0.0 = inf
division by zero reported
1.0/10 = 0.1
inexact result reported
sqrt(-1) = -nan
invalid result reported

[editar] Ver también

Define el mecanismo de control de errores usado por las funciones matemáticas comunes
(constante de macro) [editar]