openroberta-lab icon indicating copy to clipboard operation
openroberta-lab copied to clipboard

Random/Zufallszahl 0.0 - 1.0 won't work because of integer division

Open Andy1978 opened this issue 1 year ago • 0 comments

Following sketch grafik

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

Andy1978 avatar Mar 12 '24 10:03 Andy1978