Lua math.random返回不稳定的值

Yan*_*hon 2 random lua

我想知道为什么我的脚本数据无效,然后我试着测试,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
Run Code Online (Sandbox Code Playgroud)

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

Mar*_*c B 7

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

upper和lower必须是整数.在其他情况下,Lua将上部转换为整数,有时给出math.floor(上部)和其他math.ceil(上部),具有意外结果(对于较低的结果相同).