std::feraiseexcept
Материал из 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. |
| Заголовочный файл <cfenv>
|
||
| int feraiseexcept( int excepts ); |
(начиная с C++11) | |
Попытки поднять все плавающей точкой исключений, перечисленных в
excepts (побитовое ИЛИ плавающей точкой макросы исключение). Если одно из исключений является FE_OVERFLOW или FE_UNDERFLOW, эта функция может дополнительно повышать FE_INEXACT. Порядок, в котором возникновении исключений не определен, кроме того, что FE_OVERFLOW и FE_UNDERFLOW всегда вызывается перед FE_INEXACT.Original:
Attempts to raise all floating point exceptions listed in
excepts (a bitwise OR of the плавающей точкой макросы исключение). 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.
Содержание |
[править] Параметры
| excepts | - | битовой маски, перечисляя за исключением флага поднять
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. |
[править] Возвращаемое значение
0, если все перечисленные исключения были подняты, ненулевое значение, в противном случае.
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.
[править] Пример
#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"; } }
Вывод:
Raising divbyzero and underflow simultaneously succeeds and results in division by zero underflow
[править] См. также
| (C++11) |
очищает указанный плавающей точкой флаги статуса Original: clears the specified floating-point status flags The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (функция) |
| (C++11) |
определяет, какая из указанных плавающей точкой флаги состояния устанавливаются Original: determines which of the specified floating-point status flags are set The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (функция) |