Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

math function in javascript exponentiation

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

like image 876
Ilya Libin Avatar asked Sep 26 '26 01:09

Ilya Libin


1 Answers

The ^ is actually a bitwise XOR operator. You're looking for Math.pow():

alert(Math.pow((0.03+1), (271/365))-1);
like image 60
bfavaretto Avatar answered Sep 28 '26 14:09

bfavaretto



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!