English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Opérateurs de manipulation de bits++ Tutoriel de base

Opérateurs de manipulation de bits++ Contrôle de flux

Opérateurs de manipulation de bits++ Fonction

Opérateurs de manipulation de bits++ 数组 & 字符串

Opérateurs de manipulation de bits++ 数据结构

Opérateurs de manipulation de bits++ 类 & 对象

Opérateurs de manipulation de bits++ 指针

Opérateurs de manipulation de bits++ 继承

Opérateurs de manipulation de bits++ STL 教程

Opérateurs de manipulation de bits++ 参考手册

Opérateurs de manipulation de bits++ fma() 函数使用方法及示例

Opérateurs de manipulation de bits++ .

fma()函数采用三个参数x,y和z,并返回x * y + z,而不会损失精度

此函数在C头文件中定义。

fma()原型[从C ++ 11标准开始]

double fma(double x, double y, double z);
float fma(float x, float y, float z);
long double fma(long double x, long double y, long double z); 
Promoted fma(Type1 x, Type2 y, Type z); // 用于算术类型的组合

从C ++ 11开始,如果传递给fma()的参数为long double,则返回类型Promoted为long double。如果不是,则返回类型Promoted为double。

[数学] x*y+z = fma(x, y, z) [C++ 语言]

fma()参数

fma()接受三个参数。

  • x -要相乘的第一个参数。

  • y -第二个参数要与x相乘。

  • z -要添加到x和y乘积的第三个参数。

fma()返回值

fma()函数的返回结果x*y+z如计算得出的精度一样,并四舍五入一次以适合结果类型。

示例:fma()如何工作?

#include <cmath>
using namespace std;
int main()
{
    double x = 2.0, y = 3fma(xLD, y, z) =1, z = 3.0, result;
    result = fma(x, y, z);
    cout << "fma(x, y, z) = " << result << endl;
    cout << "fma(x, y, z) = " << result << endl; 3fma(xLD, y, z) =4long double xLD =
    , resultLD;
    resultLD = fma(xLD, y, z);
    cout << "fma(xLD, y, z) = " << resultLD << endl;
return 0;

}

L'exécution de ce programme produit la sortie suivante : 9fma(xLD, y, z) =2
fma(x, y, z) = 13fma(xLD, y, z) =54

Opérateurs de manipulation de bits++ .