Seems to be a bug with random integer

When I use this simple program I made and select the low and high to be say 8 and 9. It generates numbers between 0 and 1. If I choose 10 and 12 it generates numbers between 0 and 2. Anybody have an idea of what’s going on?

1 Like

1 Like

The problem is that you’re asking Thunkable to generate a random number from text strings. It doesn’t know how to do that properly. So you have to first convert the text to numbers.

The forums won’t let me post an image at the moment but if you add zero to each text input block (using the math block for addition), it will work properly.

Edit: also, see @Deluxe’s screenshot.

2 Likes

Thanks. That worked. I didn’t think you had to typecast in Thunkable as I couldn’t find any blocks to do so. I kinda thought that was happening but when I tried to put strings into test that theory it wouldn’t let me put them directly into the random block and when I tried to pull the string from the hint on the text box it gave me NaN which I knew was because it was trying to use a string.

The strange thing is that it new the numerical difference between the two values that were text i.e 5 and 8 it would generate 0,1,2,3 and 5 and 6 would generate 0,1.

Thanks again.

1 Like

Yeah, I noticed that, too. Thunkable does check some types and won’t let you fit blocks together but it’s fairly lenient.

1 Like