pow(2,1 / 2)!= pow(2,0.5)问题 [英] pow(2, 1/2) != pow(2, 0.5) problem
问题描述
我从pow()函数中获得了一个不需要的行为:
执行pow(2,0.5)时,我在执行pow时获得1.414214
(2,1 / 2),当执行a = 0.5时,我获得1.000000
; pow(2,a),当执行a = 1/2时,我获得1.414214
; pow(2,a),我获得1.000000
怎么来的???我怎么能做一个pow(x,y)所以我的y是两个
其他变量的分数? (因为现在它的行为好像y中的两个
变量的一部分被截断了)
Michel Rouzic <弥******** @ yahoo.fr>写道:
我从pow()函数中获得了一个不需要的行为:
当执行pow(2,0.5)时,我获得1.414214
当执行pow(2,1 / 2)时,我获得1.000000
你的问题不在于pow();它是整数数学。
1/2又是多少?和1.0 / 2?
Richard
Richard Bos写道:< blockquote class =post_quotes>" Michel Rouzic" <弥******** @ yahoo.fr>写道:
我从pow()函数中获得了一个不需要的行为:
当执行pow(2,0.5)时,我获得1.414214
当执行pow(2,1 / 2)时,我获得1.000000
你的问题不在于pow();它是整数数学。再多少是多少?和1.0 / 2?
理查德
所以我必须在我的所有数字的末尾添加.0才能使其正常工作?
Le 15/06/2005 12:50,dans
11 ******************* ***@f14g2000cwb.googlegroups。 com ,?* Michel Rouzic *?
< Mi ******** @ yahoo.fr> aécrit*:
Richard Bos写道:" Michel Rouzic" <弥******** @ yahoo.fr>写道:
我从pow()函数中获得了一个不需要的行为:
当执行pow(2,0.5)时,我获得1.414214
当执行pow(2,1 / 2)时,我获得1.000000
你的问题不在于pow();它是整数数学。再多少是多少?并且1.0 / 2?
理查德
所以我必须在我的所有数字的末尾添加.0才能使其正常工作?
我会说这是一个好习惯...否则有一天你会忘记,并且
再次写1/2,但是在一个地方很难找到。
I obtain an unwanted behavior from the pow() function :
when performing pow(2, 0.5), i obtain 1.414214
when performing pow(2, 1/2), i obtain 1.000000
when performing a=0.5; pow(2, a), i obtain 1.414214
when performing a=1/2; pow(2, a), i obtain 1.000000
how come??? and how can i do a pow(x, y) so my y is the fraction of two
other variables? (cuz for now it acts as if that fraction of two
variables in y was truncated)
"Michel Rouzic" <Mi********@yahoo.fr> wrote:
I obtain an unwanted behavior from the pow() function :
when performing pow(2, 0.5), i obtain 1.414214
when performing pow(2, 1/2), i obtain 1.000000
Your problem is not with pow(); it is with integer maths. How much is
1/2, again? And 1.0/2?
Richard
Richard Bos wrote:"Michel Rouzic" <Mi********@yahoo.fr> wrote:I obtain an unwanted behavior from the pow() function :
when performing pow(2, 0.5), i obtain 1.414214
when performing pow(2, 1/2), i obtain 1.000000
Your problem is not with pow(); it is with integer maths. How much is
1/2, again? And 1.0/2?
Richard
so i gotta add .0 at the end of all my numbers in order to make it work?
Le 15/06/2005 12:50, dans
11**********************@f14g2000cwb.googlegroups. com, ?*Michel Rouzic*?
<Mi********@yahoo.fr> a écrit*:
Richard Bos wrote:"Michel Rouzic" <Mi********@yahoo.fr> wrote:I obtain an unwanted behavior from the pow() function :
when performing pow(2, 0.5), i obtain 1.414214
when performing pow(2, 1/2), i obtain 1.000000
Your problem is not with pow(); it is with integer maths. How much is
1/2, again? And 1.0/2?
Richard
so i gotta add .0 at the end of all my numbers in order to make it work?
It''s a good habit I would say... Otherwise one day you will forget, and
write 1/2 again, but in a place it will very difficult to find.
这篇关于pow(2,1 / 2)!= pow(2,0.5)问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!