mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 11:48:02 -04:00
Merge branch 'master' of github.com:MightyPirates/OpenComputers
This commit is contained in:
commit
984123efdc
@ -211,15 +211,15 @@ public class MathLib extends TwoArgFunction {
|
|||||||
return valueOf( random.nextDouble() );
|
return valueOf( random.nextDouble() );
|
||||||
}
|
}
|
||||||
public LuaValue call(LuaValue a) {
|
public LuaValue call(LuaValue a) {
|
||||||
int m = a.checkint();
|
double m = a.checkdouble();
|
||||||
if (m<1) argerror(1, "interval is empty");
|
if (m<1) argerror(1, "interval is empty");
|
||||||
return valueOf( 1 + random.nextInt(m) );
|
return valueOf( Math.floor(random.nextDouble() * m) + 1L );
|
||||||
}
|
}
|
||||||
public LuaValue call(LuaValue a, LuaValue b) {
|
public LuaValue call(LuaValue a, LuaValue b) {
|
||||||
int m = a.checkint();
|
double m = a.checkdouble();
|
||||||
int n = b.checkint();
|
double n = b.checkdouble();
|
||||||
if (n<m) argerror(2, "interval is empty");
|
if (n<m) argerror(2, "interval is empty");
|
||||||
return valueOf( m + random.nextInt(n+1-m) );
|
return valueOf( Math.floor(random.nextDouble() * (n - m + 1)) + m );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user