Variable problem in mBlock


#1

Hi,

I made a small example of my problem.
If I directly display a random number on the Codey, I do not have a decimal.
However, if I go through a variable, I have plenty of decimal.

I try to round up and take a floor function but nothing works.
The IOS and PC version have the same behavior.


#2

That is normal, scratch only supports integers in random number generation. So does mBlock5.


#3

So how to generate an integer in a loop that goes from 20 to 1.

Example:

Random number between 1 and 20
for the second pass
Random number between 1 and 19
for the third pass
Random number between 1 and 18

How do you explain the difference between the Codey device display (3 décimal):
2

and the display of Sprites (0 décimal) in mBlock5?
1


#4

If we have below block, it will be integers only.
image

image
With this code, you can get 3 decimals?


#5

On the display of Codey is obtained 3 decimals.

Ex.: 9.098 or 4.321

While with mBlock sprites, get 0 decimal.

Ex: 9 or 4


#6

That is not the same as in my test. Would you check my email please?


#7

Received a support message from Stephanie.

  • I installed RC version 5.0.
  • I updated my Codey.

Conclusion: It works very well. I do not know if the problem was in version 5.0 Beta4 of mBlock or in the Fireware of Codey.

Thank you