C 庫 - <fenv.h>



fenv.h 標頭檔案是標準 C 庫的一部分,定義了用於操作浮點環境的各種函式和宏。它允許我們控制與浮點運算相關的方面,例如異常處理和舍入模式。

C − fenv.h 型別

以下是 fenv.h 標頭檔案中定義的型別:

序號 型別及描述
1

fenv_t

此型別表示整個浮點環境。

2

fexcept_t

此型別表示所有浮點狀態標誌的集合。

庫函式

以下是 fenv.h 標頭檔案中定義的函式:

序號 函式及描述
1 int feclearexcept( int excepts )

此函式清除指定的浮點狀態標誌。

2 int fetestexcept( int excepts )

此函式確定哪些指定的浮點狀態標誌已設定。

3 int feraiseexcept(int excepts)

此函式引發指定的浮點異常。

4 int fegetexceptflag( fexcept_t* flagp, int excepts )

此函式檢索浮點異常標誌的完整內容。

5 int fesetexceptflag(const fexcept_t *flagp, int excepts)

此函式設定浮點異常標誌的內容。

6 int fegetround()

此函式檢索舍入方向。

7 int fesetround( int round )

此函式設定舍入方向。

8 int fegetenv( fenv_t* envp )

此函式嘗試將浮點環境的狀態儲存到 envp 指向的物件中。

9 int fesetenv( const fenv_t* envp )

此函式嘗試從 envp 指向的物件中建立浮點環境。

10 int feholdexcept( fenv_t* envp )

此函式儲存環境,清除所有狀態標誌並忽略所有將來的錯誤。

11 int feupdateenv( const fenv_t* envp )

此函式恢復浮點環境並引發先前引發的異常。

廣告