名前空間
変種
操作

std::fegetround, std::fesetround

提供: 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>
int fesetround( int round )
(1) (C++11およびそれ以降)
int fegetround()
(2) (C++11およびそれ以降)
1)
roundの一つとして期待されている引数浮動小数点の丸めのマクロに等しい浮動小数点の丸め方向を確立しようと.
Original:
Attempts to establish the floating-point rounding direction equal to the argument round, which is expected to be one of the 浮動小数点の丸めのマクロ.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
現在の丸め方向に対応浮動小数点の丸めのマクロの値を返します。.
Original:
Returns the value of the 浮動小数点の丸めのマクロ that corresponds to the current rounding direction.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] パラメータ

round -
丸め方向、浮動小数点の丸めのマクロの一つ
Original:
rounding direction, one of 浮動小数点の丸めのマクロ
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 値を返します

1)
0成功した場合には、ゼロ以外のその他のとき.
Original:
0 on success, non-zero otherwise.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
方向が決定できない場合浮動小数点の丸めのマクロは、現在の丸め方向または負の値を記述する
Original:
the 浮動小数点の丸めのマクロ describing the current rounding direction or a negative value if the direction cannot be determined
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集]

[edit]
#include <cmath>
#include <cfenv>
#include <iostream>
 
int main()
{
    #pragma STDC FENV_ACCESS ON
    std::fesetround(FE_DOWNWARD);
    std::cout << "rounding using FE_DOWNWARD: \n" << std::fixed
              << " 12.0 ->  " << std::nearbyint(12.0) << '\n'
              << " 12.1 ->  " << std::nearbyint(12.1) << '\n'
              << "-12.1 -> " << std::nearbyint(-12.1) << '\n'
              << " 12.5 ->  " << std::nearbyint(12.5) << '\n'
              << " 12.9 ->  " << std::nearbyint(12.9) << '\n'
              << "-12.9 -> " << std::nearbyint(-12.9) << '\n'
              << " 13.0 ->  " << std::nearbyint(13.0) << '\n';
    std::fesetround(FE_TONEAREST);
    std::cout << "rounding using FE_TONEAREST: \n"
              << " 12.0 ->  " << std::nearbyint(12.0) << '\n'
              << " 12.1 ->  " << std::nearbyint(12.1) << '\n'
              << "-12.1 -> " << std::nearbyint(-12.1) << '\n'
              << " 12.5 ->  " << std::nearbyint(12.5) << '\n'
              << " 12.9 ->  " << std::nearbyint(12.9) << '\n'
              << "-12.9 -> " << std::nearbyint(-12.9) << '\n'
              << " 13.0 ->  " << std::nearbyint(13.0) << '\n';
}

Output:

rounding using FE_DOWNWARD:
 12.0 ->  12.000000
 12.1 ->  12.000000
-12.1 -> -13.000000
 12.5 ->  12.000000
 12.9 ->  12.000000
-12.9 -> -13.000000
 13.0 ->  13.000000
rounding using FE_TONEAREST: 
 12.0 ->  12.000000
 12.1 ->  12.000000
-12.1 -> -12.000000
 12.5 ->  12.000000
 12.9 ->  13.000000
-12.9 -> -13.000000
 13.0 ->  13.000000

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

(C++11)
現在の丸めモードを使用して、最も近い整数
Original:
nearest integer using current rounding mode
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(関数) [edit]
(C++11)
(C++11)
(C++11)
結果が異なる場合
を除いて、現在の丸めモードを使用して、最も近い整数
Original:
nearest integer using current rounding mode with
exception if the result differs
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(関数) [edit]