GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::feraiseexcept(3) C++ Standard Libary std::feraiseexcept(3)

std::feraiseexcept - std::feraiseexcept


Defined in header <cfenv>
int feraiseexcept( int excepts ); (since C++11)


Attempts to raise all floating point exceptions listed in excepts (a bitwise OR of
the floating point exception macros). 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.


excepts - bitmask listing the exception flags to raise


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

// Run this code


#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


feclearexcept clears the specified floating-point status flags
(C++11) (function)
fetestexcept determines which of the specified floating-point status flags are set
(C++11) (function)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.