OpenRoberta / openroberta-lab

The programming environment »Open Roberta Lab« by Fraunhofer IAIS enables children and adolescents to program robots. A variety of different programming blocks are provided to program motors and sensors of the robot. Open Roberta Lab uses an approach of graphical programming so that beginners can seamlessly start coding. As a cloud-based application, the platform can be used without prior installation of specific software but runs in any popular browser, independent of operating system and device.
Apache License 2.0
122 stars 118 forks source link

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

Closed Andy1978 closed 1 week ago

Andy1978 commented 3 months ago

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