mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 19:25:20 -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() );
|
||||
}
|
||||
public LuaValue call(LuaValue a) {
|
||||
int m = a.checkint();
|
||||
double m = a.checkdouble();
|
||||
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) {
|
||||
int m = a.checkint();
|
||||
int n = b.checkint();
|
||||
double m = a.checkdouble();
|
||||
double n = b.checkdouble();
|
||||
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