gpt4 book ai didi

random - Lua math.random 返回不稳定的值

转载 作者:行者123 更新时间:2023-12-01 11:50:18 25 4
gpt4 key购买 nike

我想知道为什么我的脚本数据无效,然后我尝试测试 math.random,因为它似乎来自它的返回值。这是我从 Lua 控制台得到的:

> return  math.random(0.8, 1.2);
0.8
> return math.random(0.8, 1.2);
0.8
> return math.random(0.8, 1.2);
0.8
> return math.random(0.8, 1.2);
1.8
> return math.random(0.8, 1.2);
0.8
> return math.random(0.8, 1.2);
1.8
> return math.random(0.8, 1.2);
0.8
> return math.random(0.8, 1.2);
1.8
> return math.random(0.8, 1.2);
0.8

我对得到的结果有点困惑。有人可以澄清一下吗?

最佳答案

http://lua-users.org/wiki/MathLibraryTutorial

upper and lower must be integer. In other case Lua casts upper into an integer, sometimes giving math.floor(upper) and others math.ceil(upper), with unexpected results (the same for lower).

关于random - Lua math.random 返回不稳定的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30086158/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com