Skip to content

Commit d985e1d

Browse files
author
Maxim Sergeev
committed
Issue yuin#168 : math.random(upper) now works fine when upper=1
1 parent 84ea3a3 commit d985e1d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: mathlib.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func mathRandom(L *LState) int {
189189
L.Push(LNumber(rand.Float64()))
190190
case 1:
191191
n := L.CheckInt(1)
192-
L.Push(LNumber(rand.Intn(n-1) + 1))
192+
L.Push(LNumber(rand.Intn(n) + 1))
193193
default:
194194
min := L.CheckInt(1)
195195
max := L.CheckInt(2) + 1

0 commit comments

Comments
 (0)