# Seems to be a bug with random integer

**URL:** <https://community.thunkable.com/t/seems-to-be-a-bug-with-random-integer/1062602>\
**Category:** Questions about Thunkable X\
**Created:** [January 21, 2021, 10:13pm UTC](https://community.thunkable.com/t/seems-to-be-a-bug-with-random-integer/1062602 "2021-01-21T22:13:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ejohnsonby1sy](https://avatars.discourse-cdn.com/v4/letter/e/c77e96/32.png) [@ejohnsonby1sy](https://community.thunkable.com/u/ejohnsonby1sy)\
**Post date:** [January 21, 2021, 10:13pm UTC](https://community.thunkable.com/t/seems-to-be-a-bug-with-random-integer/1062602/1 "2021-01-21T22:13:03Z")

</div>

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?

> **[Thunkable](https://x.thunkable.com/copy/dddf2ca8d954872e954401972f120437)**

---

<div class="post-metadata">

**Author:** ![Deluxe](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/deluxe/32/30016_2.png) [@Deluxe](https://community.thunkable.com/u/Deluxe)\
**Post date:** [January 21, 2021, 11:11pm UTC](https://community.thunkable.com/t/seems-to-be-a-bug-with-random-integer/1062602/2 "2021-01-21T23:11:35Z")

</div>

![Screenshot 2021-01-22 at 01.11.07](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/b/cbf38783af2727bb82b5fc3538dbd8390221337f.png)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 21, 2021, 11:12pm UTC](https://community.thunkable.com/t/seems-to-be-a-bug-with-random-integer/1062602/3 "2021-01-21T23:12:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ejohnsonby1sy](https://avatars.discourse-cdn.com/v4/letter/e/c77e96/32.png) [@ejohnsonby1sy](https://community.thunkable.com/u/ejohnsonby1sy)\
**Post date:** [January 21, 2021, 11:31pm UTC](https://community.thunkable.com/t/seems-to-be-a-bug-with-random-integer/1062602/4 "2021-01-21T23:31:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 22, 2021, 1:25am UTC](https://community.thunkable.com/t/seems-to-be-a-bug-with-random-integer/1062602/5 "2021-01-22T01:25:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 1:30pm UTC](https://community.thunkable.com/t/seems-to-be-a-bug-with-random-integer/1062602/6 "2024-11-08T13:30:34Z")

</div>


