I have some calculation in javascript that includes exponentiation.
Can any of you say why does this sentence return value 1???
alert ((0.03+1)^(271/365)-1);
Thanks
I have some calculation in javascript that includes exponentiation.
Can any of you say why does this sentence return value 1???
alert ((0.03+1)^(271/365)-1);
Thanks
The ^
is actually a bitwise XOR operator. You're looking for Math.pow()
:
alert(Math.pow((0.03+1), (271/365))-1);
Math.pow( (0.03+1), ((271/365)-1) )
will give you a result of 0.9924164970995866