math.pow alternative in Lua?

Viewed 13131

I cannot use math.pow(x,y) in Lua.

I don't know why, it says syntax error.

math.sin(f) and math.cos(f) works however.

Is there other alternative for math.pow() in Lua?

1 Answers

Lua has no math.pow() function.

Correction: Lua's math.pow() function is deprecated as of release 5.3, as documented here. But it still exists in the latest release (up to and including 5.4.0-work2).

If you're getting a syntax error, it's due to some other problem. Please update your question to show us the exact code that produces the error, as well as the error message.

In any case, you should use the built-in ^ exponentiation operator rather than the math.pow() function.

(Unlike C and some other languages, Lua uses ~ as the bitwise xor operator.)

Related