名前空間
変種
操作

FE_DFL_ENV

提供: cppreference.com
< cpp‎ | numeric‎ | fenv

 
 
ニューメリックスライブラリ
一般的な数学関数
浮動小数点環境
複素数
数値配列
擬似乱数生成
コンパイル時有理数演算 (C++11)
汎用の数値演算
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.
iota(C++11)
accumulate
inner_product
adjacent_difference
partial_sum
 
浮動小数点環境
機能します
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
feclearexcept(C++11)
fetestexcept(C++11)
feraiseexcept(C++11)
fegetexceptflag
fesetexceptflag
(C++11)
(C++11)
fegetround
fesetround
(C++11)
(C++11)
fegetenv
fesetenv
(C++11)
feholdexcept(C++11)
feupdateenv(C++11)
マクロ定数
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.
FE_ALL_EXCEPT
FE_DIVBYZERO
FE_INEXACT
FE_INVALID
FE_OVERFLOW
FE_UNDERFLOW
(C++11)
FE_DOWNWARD
FE_TONEAREST
FE_TOWARDZERO
FE_UPWARD
(C++11)
FE_DFL_ENV(C++11)
 
Defined in header <cfenv>
#define FE_DFL_ENV  /*implementation defined*/
(C + + 11以来)
マクロ定数FE_DFL_ENVは、プログラムの起動時にロードされるような環境であり、デフォルトの浮動小数点環境の完全なコピーを指し示しタイプconst std::fenv_t*、の式に展開されます.
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.
大文字が続くFE_で始まり、タイプconst std::fenv_t*を持つ追加のマクロは、実装によってサポートされるかもしれません.
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.

[編集]

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

Output:

On startup: 
rounding to nearest
 
Before restoration: 
underflow is raised
overflow is raised
rounding up
 
After reset to default: 
rounding to nearest

[編集] も参照してください

現在の浮動小数点環境を保存したり復元します
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.

(機能) [edit]
浮動小数点環境を復元し、以前に例外を発生させることが発生します
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.

(機能) [edit]