跳轉到內容

C 程式設計/fenv.h

來自華夏公益教科書,開放的書籍,開放的世界

fenv.h 是一個頭檔案,包含用於操作浮點環境的各種函式和宏。[1]

此標頭檔案聲明瞭兩種型別,fenv_t(表示整個浮點環境)和 fexcept_t(表示浮點狀態標誌)。[1] 它還聲明瞭幾個特徵宏,以 FE_ 和一個大寫字母開頭。

除了 fegetroundfetestexcept 之外,這些函式在成功/失敗時返回零/非零。

宣告 描述
int feclearexcept(int excepts); 清除由 excepts 指定的異常
int fegetenv(fenv_t *penv); 將當前浮點環境儲存在 penv
int fegetexceptflag(fexcept_t *pflag, int excepts); 將當前狀態標誌儲存在 pflags
int fegetround(void); 檢索當前舍入方向
int feholdexcept(fenv_t *penv); 將當前浮點環境儲存到 penv 並清除所有異常
int feraiseexcept(int excepts); 引發浮點異常
int fesetenv(const fenv_t *penv); 將當前浮點環境設定為 penv
int fesetexceptflag(const fexcept_t *pflags, int excepts); 將當前狀態標誌設定為儲存在 pflags 中的那些標誌
int fesetround(int round); 將當前舍入方向設定為 round
int fetestexcept(int excepts); 測試是否已引發某些異常
int feupdateenv(const fenv_t *penv); 恢復浮點環境 penv,但保留當前異常
int fesetprec(int prec) 將精度模式設定為 prec 指定的值。

參考資料

[編輯 | 編輯原始碼]
  1. a b fenv.h: 浮點環境 – 基本定義參考,The Single UNIX® Specification,The Open Group 的第 7 版
華夏公益教科書