openroberta-lab
openroberta-lab copied to clipboard
Random/Zufallszahl 0.0 - 1.0 won't work because of integer division
Following sketch
translates to
...
float ___x;
task main() {
___x = 0;
while ( true ) {
___x = Random(100) / 100;
NumOut(0, (MAXLINES - 1) * MAXLINES, ___x);
NumOut(0, (MAXLINES - 2) * MAXLINES, Random(100) / 100);
Wait(1000);
}
}
which always shows
0
0
due to integer division. The simulations shows the expected float values. A fix would be to use Random(100) / 100.0, I'll provide a patch for this soon