admin管理员组文章数量:1794759
C++的POW()函数用法介绍,也即幂函数的使用方法
POW()函数的原型为:
#include <math.h>
double pow( double base, double exp );
The pow() function returns base raised to the expth power. There's a domain error if base is zero and exp is less than or equal to zero. There's also a domain error if base is negative and exp is not an integer. There's a range error if an overflow occurs. |
其中解释如下:计算x的y次幂。返回值:x不能为负数且y为小数,或者x为0且y小于等于0,返回幂指数的结果。返回类型:double型,int,float会给与警告!
C++提供以下几种pow函数的重载形式:
double pow(double X,int Y);
float pow(float X,float Y);
float pow(float X,int Y);
long double pow(long double X,long double Y);
long double pow(long double X,int Y);
使用的时候应合理设置参数类型,避免有多个“pow”实例与参数列表相匹配的情况。
版权声明:本文标题:C++的POW()函数用法介绍,也即幂函数的使用方法 内容由林淑君副主任自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.xiehuijuan.com/baike/1686495484a73916.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论