Lua 中的 math.pow 替代方案? [英] math.pow alternative in Lua?

查看:548
本文介绍了Lua 中的 math.pow 替代方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不能在 Lua 中使用 math.pow(x,y).

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

我不知道为什么,它说语法错误.

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

math.sin(f)math.cos(f) 但是有效.

Lua 中的 math.pow() 是否还有其他选择?

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

推荐答案

Lua 没有 math.pow() 函数.

Lua has no math.pow() function.

更正:Lua 的 math.pow() 函数自 5.3 版起已弃用,如这里.但它仍然存在于最新版本中(直到并包括 5.4.0-work2).

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.

在任何情况下,您都应该使用内置的 ^ 求幂运算符而不是 math.pow() 函数.

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

(与 C 和其他一些语言不同,Lua 使用 ~ 作为按位异或运算符.)

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

这篇关于Lua 中的 math.pow 替代方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆