We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1bcbe19 commit 00e4e9cCopy full SHA for 00e4e9c
src/com/annimon/ownlang/lib/modules/functions/std_rand.java
@@ -16,6 +16,20 @@ public Value execute(Value... args) {
16
Arguments.checkRange(0, 2, args.length);
17
if (args.length == 0) return NumberValue.of(RND.nextDouble());
18
19
+ final Object raw = args[0].raw();
20
+ if (raw instanceof Long) {
21
+ long from = 0L;
22
+ long to = 100L;
23
+ if (args.length == 1) {
24
+ to = (long) raw;
25
+ } else if (args.length == 2) {
26
+ from = (long) raw;
27
+ to = ((NumberValue) args[1]).asLong();
28
+ }
29
+ final long randomLong = RND.nextLong() >>> 1;
30
+ return NumberValue.of(randomLong % (to - from) + from);
31
32
+
33
int from = 0;
34
int to = 100;
35
if (args.length == 1) {
0 commit comments