OvermindDL1 / bucklescript-tea

TEA for Bucklescript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug in Random.int

seadynamic8 opened this issue · comments

I think there is a bug in the random generator, at least for Integers.

When I run this code:

Random.generate updateRandom (Random.int low high)

It works fine initially, when set through the init function, but once the model updates either the high or low values, it will sometimes give me a random number a few above the high number.

So if set to low:0 and high: 10, it will give me between 0 and 10 initially.

But if I change, lets say the low: 3, I will get values from 3 to 13.

This happens if I change the high value as well.

I also converted my code over to Elm to see if it works there. It doesn't have a problem in Elm, so I think there maybe a bug in bucklescript-tea.

Oh, I'm using the high as the 'range above the minimum', is that not how Elm's API does it? https://package.elm-lang.org/packages/elm-lang/core/latest/Random#int Indeed it does not, let me fix that right quick, and done and released as 0.8.0 (major version bump due to api change). :-)

Great. Thanks!