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

查看:127
本文介绍了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.

更正:从

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天全站免登陆