+ 1
Why does alert(3^(-2)) not output 1/9th?
In JavaScript, if you type in: alert(3^(-2)); output = -3 In a calculator: 3^(-2) like you'd expect, output = 1/9th Why does JavaScript not give that output?
4 Réponses
+ 16
alert(Math.pow(3,-2))
+ 16
^ (carret) is the bitwise XOR operator...
+ 4
Of course, forgot about that, thanks!
+ 2
In programming the '^' is used for something else.....
Use Math.pow(3,-2) instead