GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • cpprefjp - C++日本語リファレンス
  • GitHub Project

This view

  • Original page
  • New address

GeezerVison is showing cpprefjp.github.io — FE_DIVBYZERO - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. cfenv
  3. FE_DIVBYZERO

最終更新日時: 2026年09月11日 13時06分31秒 (JST)
Akira Takahashi が更新

履歴 編集

macro
<cfenv>

FE_DIVBYZERO(C++11)

#define FE_DIVBYZERO integer-constant-expression
// または
#undef FE_DIVBYZERO

概要

浮動小数点数に対してゼロで除算されたことを表す浮動小数点例外の種類。

「DIVBYZERO」は「divide-by-zero (ゼロによる除算)」の略称である。

処理系がこの浮動小数点例外に対応している場合にこのマクロが定義される。 マクロが定義されるとき、このマクロは浮動小数点例外の状態を表すビット値である。他の浮動小数点例外マクロとAND (&) や OR (|)を使用して、複数のマクロを組み合わせて使用できる。

例

#include <iostream>
#include <cfenv>

int main()
{
  float result = 1.0f / 0.0f;
  if (std::fetestexcept(FE_DIVBYZERO)) {
    // 浮動小数点数に対してゼロ除算が行われた
    std::cout << "zero divided" << std::endl;
  }
  else {
    std::cout << "no error" << std::endl;
  }
  std::feclearexcept(FE_ALL_EXCEPT);
}

出力例

zero divided

バージョン

言語

  • C++11

処理系

  • Clang: 3.0 ✅
  • GCC: 4.3.0 ✅
  • Visual C++: 2013 ✅, 2015 ✅
    • コンパイルオプション/fp:strictまたは#pragma fenv_access (on)が必要。さもなくば、正しく動作しないおそれがある。
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.