tgamma()函数计算传递给该函数的参数的gamma函数。
假设数字是 x:
float tgamma(float x); double tgamma(double x); long double tgamma(long double x); double tgamma(double x);
x :这是一个浮点值。
它返回x的伽玛函数值。
参数 | 返回值 |
---|---|
x = ±0 | ±∞ |
x = -ve | nan |
x = -∞ | nan |
x = +∞ | +∞ |
x = nan | nan |
让我们看一个简单的例子,当x的值为零时。
#include <iostream> #include<math.h> using namespace std; int main() { float x= 0.0; cout<<"Value of x is : "<<x<<'\n'; cout<<"tgamma(x) : "<<tgamma(x); return 0; }
输出:
Value of x is : 0 tgamma(x) : inf
在上面的示例中,x的值为零,因此函数tgamma()返回+∞。
让我们看一个简单的例子,当x的值为负数时。
#include <iostream> #include<math.h> using namespace std; int main() { int x= -6; cout<<"Value of x is : "<<x<<'\n'; cout<<"tgamma(x) : "<<tgamma(x); return 0; }
输出:
Value of x is : -6 tgamma(x) : nan
在上面的示例中,x的值为负整数。因此,函数tgamma()返回nan。
让我们看一下x的值为-∞时的简单示例。
#include <iostream> #include<math.h> using namespace std; int main() { float x= -9.0/0.0; cout<<"Value of x is : "<<x<<'\n'; cout<<"tgamma(x): "<<tgamma(x); return 0; }
输出:
Value of x is : -inf tgamma(x): nan
在上面的示例中,x-∞的值。因此,函数tgamma()返回nan。
让我们看一个简单的例子,当的值为+∞时。
#include <iostream> #include<math.h> using namespace std; int main() { float x= 7.8/0.0; cout<<"Value of x is : "<<x<<'\n'; cout<<"tgamma(x) : "<<tgamma(x); return 0; }
输出:
Value of x is : inf tgamma(x) : inf
在上面的示例中,x的值为+∞。因此,函数tgamma()返回+∞。
让我们看一下x的值为nan时的简单示例。
#include <iostream> #include<math.h> using namespace std; int main() { float x= 0.0/0.0; cout<<"Value of x is : "<<x<<'\n'; cout<<"tgamma(x) : "<<tgamma(x); return 0; }
输出:
Value of x is : -nan tgamma(x) : -nan
在上面的示例中,x的值为nan。因此,函数tgamma()返回nan。
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)
Spring Boot与Kubernetes云原生微服务实践 -〔杨波〕