Skip to content

Commit

Permalink
Issue #168 : math.random(upper) now works fine when upper=1
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Sergeev committed Mar 22, 2018
1 parent 84ea3a3 commit d985e1d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mathlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func mathRandom(L *LState) int {
L.Push(LNumber(rand.Float64()))
case 1:
n := L.CheckInt(1)
L.Push(LNumber(rand.Intn(n-1) + 1))
L.Push(LNumber(rand.Intn(n) + 1))
default:
min := L.CheckInt(1)
max := L.CheckInt(2) + 1
Expand Down

0 comments on commit d985e1d

Please sign in to comment.