[FIXED] Random Integer generator diff between wick versions

Not sure if this is intended or not, but the following function behaves different in 1.18 and 1.19:

random.integer(min, max)

in version 1.18 returns a number between min and max including the min and max.
in version 1.19 returns a number between min and max including min and max - 1.

Screen Shot 2021-01-05 at 9.30.20 PM

@Luxapodular:
Not sure why this is changing or if this is something that your team is not aware.

1 Like

Yes, this was changed while a bug fix was implemented by @sporklpony! https://github.com/Wicklets/wick-editor/issues/39

The previous version would go from min to max+1.

I believe this was intended to make the random value go from min to max - .00000001 (Some very small amount). This is in line with many other tools, but what are your thoughts?

Well the problem is that I was doing something in 1.18 wich right now the code editor is more stable, but I want to test the performance in 1.19, and it is not compatible anymore… I had to adjust the max limit to make it work.

Apologies for that Jovanny. This was definitely a bug in the previous implementation so I think it should be fixed, but if you can think of a way to get around this then I’d be happy to consider how to integrate it into the spec.

This is an example… in v1.18
random.integer(1,3); genarates 1,2,1,3,2,1,3,2,31,1 and so on…

While v1.19 generates
1,2,2,1,1,2,1,1,2,2,1,1

Hmm, I definitely think random.integer should hit this max bound, while random.float should not. This should be a simple change.

1 Like

Here is a short example just in case you need it for testing…
My Project1-6-2021_12-36-09PM.wick (2.1 KB)

This has been fixed on the test branch. Give it a shot!

2 Likes

Yup, Now the function is behaving the same in both versions. Thank you for this quick fix.