关于C++指数次幂运算pow函数的用法
时间:2022-12-09 15:30:00
pow函数求指数次幂运算函数
#include
#include
函数原型是double pow(double a,double b);
功能: 以参数返回函数base 为底的exp 次幂。如果base为零或负和exp 当小于或等于零或非整数时,会产生域错误。如果溢出,范围错误
C 提供以下几种pow函数重载形式:
double pow(double base,double exp );
double pow(double base,int exp );
float pow(float base,float exp );
float pow(float base,int exp );
long double pow(long double base,long double exp );
long double pow(long double base,int exp );
使用时应合理设置参数类型,避免多个pow实例与参数列表相匹配。