Equasion do not matchArchives Forums/Blitz3D Bug Reports/Equasion do not match
| I do not know if i write this good but i give it a try:|
Repeat test =(Rnd(1) = 1) test2 = Rnd(2) Print test+" "+test2 Until test = 1
this wil always produce a 0 and a number 1 or 2
But this is wrong i think.
The first TEST is a equasion and that has to test rnd(1) against the 1. This has to result in a 1 and not a 0.
Is this a bug or do i see it wrong.
if ou say i see it wrong then why is this one working:
Repeat test =(Rnd(1) and 1) test2 = Rnd(2) Print test+" "+test2 Until test = 1
its alse a equasion only this on is testing the bits.
| You may be confusing Rnd(), which is a floating point value, with the integer Rand().|
The unexpected results happen because you are mixing floats and integers. The Language Reference gives the details of this, in the Expressions section. Unfortunately this is not online. You can find it on the Home Page of the IDE.
(Rnd(1) = 1) is a comparison and the 1 is converted to 1.0, a float. It is False because Rnd(1) < 1.
(Rnd(1) and 1) is a bitwise operation so Rnd(1) is converted to integer by rounding. It can be 0 or 1.
| Thank for the tip. Your right i was not thinking of that.|
i try it to find out if that is working.
| its working thanks for the tip. |