如何提高了12力量的双重价值? [英] How to raise a double value by power of 12?
问题描述
我有一个双是:
double mydouble = 10;
和我想10 ^ 12,所以10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10。我试过
and I want 10^12, so 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10. I tried
double newDouble = pow(10, 12);
和它返回我的NSLog: POW = -1.991886
and it returns me in NSLog: pow=-1.991886
使得没有太大意义......我想战俘是不是我的朋友吧?
makes not much sense... I think pow isn't my friend right?
推荐答案
尝试POW(10.0,12.0)。更妙的是,的#include文件math.h
。
try pow(10.0, 12.0). Better yet, #include math.h
.
要澄清:如果不包括 math.h中,编译器假定 POW()
返回一个整数。包括math.h中带来了一个原型像
To clarify: If you don't include math.h, the compiler assumes that pow()
returns an integer. Including math.h brings in a prototype like
double pow(double, double);
所以编译器可以了解如何治疗的参数和返回值。
So the compiler can understand how to treat the arguments and the return value.
这篇关于如何提高了12力量的双重价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!