[ Web Proxy ]
URL:
Viewing: https://ru.cppreference.com/cpp/numeric/fenv/feraiseexcept [Back]  [Original]

std::feraiseexcept cppreference.com
cppreference.com

std::feraiseexcept

cppreference.com

<metanoindex/>

 
C++
(C++20)
(C++20)
(C++11)
(C++20)
/
(C++11)
(C++11)
(C++11)
(C++17)
 
(C++17)
(C++20)
(C++11)
(C++11)
(C++17)
(C++17)
(C++20)
(C++20)
(C++11)
(C++17)
(C++20)
(C++23)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
 
 
<tbody> </tbody>
int feraiseexcept( int excepts );
( C++11)
, excepts ( ). FE_OVERFLOW FE_UNDERFLOW, FE_INEXACT. , , , FE_OVERFLOW FE_UNDERFLOW FE_INEXACT.
:
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.
Google.
. .

excepts
,
:
bitmask listing the exception flags to raise
Google.
. .

0, , , .
:
0 if all listed exceptions were raised, non-zero value otherwise.
Google.
. .

#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

.


() []
,
() []

Web Proxy Viewer  |  New URL  |  Original Page