Reputation: 6076
Is there a difference between 4 ^ 2
and Math.pow(4, 2);
in Actionscript 3?
Upvotes: 2
Views: 3868
Reputation: 179246
Is there a difference between
4 ^ 2
andMath.pow(4, 2);
Yes, ^
is the binary xor operator, whereas Math.pow(x, y)
raises x
to the y
power.
410 ^ 210 == 610 // 01002 xor 00102 == 01102
Math.pow(4, 2) == 16 // 42 == 16
As of ES2016, the shorthand for Math.pow(x, y)
is x**y
console.log('Using `Math.pow(4, 2)`:', Math.pow(4, 2))
console.log('Using `4**2`:', 4**2)
Upvotes: 13