Skip to content

Latest commit

 

History

History
66 lines (53 loc) · 1.47 KB

File metadata and controls

66 lines (53 loc) · 1.47 KB

fdim

  • cmath[meta header]
  • std[meta namespace]
  • function[meta id-type]
  • cpp11[meta cpp]
namespace std {
  float fdim(float x, float y);
  double fdim(double x, double y);
  long double fdim(long double x, long double y);

  Promoted fdim(Arithmetic1 x, Arithmetic2 y);

  float fdimf(float x, float y);                   // C++17 から
  long double fdiml(long double x, long double y); // C++17 から
}
  • Promoted[italic]
  • Arithmetic1[italic]
  • Arithmetic2[italic]

概要

算術型の正の差を求める。

戻り値

引数の正の差を返す。

x - y > 0 の場合は x - y を、それ以外の場合は +0 を返す。

#include <cmath>
#include <iostream>

int main() {
  std::cout << std::showpos;
  std::cout << "fdim(-1.0, 0.0) = " << std::fdim(-1.0, 0.0) << std::endl;
  std::cout << "fdim( 0.0, 0.0) = " << std::fdim( 0.0, 0.0) << std::endl;
  std::cout << "fdim(+1.0, 0.0) = " << std::fdim(+1.0, 0.0) << std::endl;
}
  • std::fdim[color ff0000]
  • std::showpos[link ../ios/showpos.md]

出力例

fdim(-1.0, 0.0) = +0
fdim( 0.0, 0.0) = +0
fdim(+1.0, 0.0) = +1

バージョン

言語

  • C++11

処理系

備考

特定の環境で constexpr 指定されている場合がある。(独自拡張)

  • GCC 4.6.1 以上