C++教程
C++控制语句
C++函数
C++数组
C++指针
C++对象
C++继承
C++多态
C++抽象
C++常用
C++ STL教程
C++迭代器
C++程序

C++ Math fma()

C++ Math fma()

该函数在不影响任何中间结果的情况下计算表达式x * y + z。
假设数字 x,y和 z :
fma(x,y,z) = x*y+z;
     

语法

float fma(float x, float y, float z);
double fma(double x, double y, double z);
long double fma(long double x, long double y, long double z);
double fma(type1 x,type2 y,type3 z);
     
注意: 如果任何参数为long double类型,则返回类型将提升为long double。如果不是,则将返回类型提升为双精度。

参数

x : 要相乘的值。
y : 将与x相乘的值。
z : 将与x和y的乘积相加的值。

返回值

它返回x * y + z的结果。

示例1

让我们看一个简单的例子。
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
    int x= 2;
    int y=3;
    int z=4;
    std::cout << "Values of x,y,z are :" <<x<<","<<y<<","<<z<< std::endl;
    cout<<"fma(x,y,z) : "<<fma(x,y,z);
    return 0;
}
     
输出:
Values of x,y,z are :2,3,4
fma(x,y,z) : 10   
     
在此示例中,fma()函数计算x * y + z的结果并返回值10、

昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4