For English Speakers passing by:
Possible bug?
Hello
I am compiling with the version-1.8.9 of ZX BASIC and the following happens:
When I put
10 DIM value, sum AS UBYTE
20 LET sum = 3
30 LET value = 1 * (sum = 3)
the value should only be: 0 or 1 depending on the value of sum
but it returns 0 or 255 (which I think it is, the maximum value of UBYTE)
In the basic of the zx spectrum if it works correctly
To fix it I put
30 LET value = 1 * ((sum = 3) / 255)
and now if it gives the correct values, but of course it adds more processing
Should it work like this or is it a bug?
Possible bug?
Hello
I am compiling with the version-1.8.9 of ZX BASIC and the following happens:
When I put
10 DIM value, sum AS UBYTE
20 LET sum = 3
30 LET value = 1 * (sum = 3)
the value should only be: 0 or 1 depending on the value of sum
but it returns 0 or 255 (which I think it is, the maximum value of UBYTE)
In the basic of the zx spectrum if it works correctly
To fix it I put
30 LET value = 1 * ((sum = 3) / 255)
and now if it gives the correct values, but of course it adds more processing
Should it work like this or is it a bug?
Quote:Yes it's normal. That is, for performance reasons, ZX Basic ensures that 0 is False, and "anything else" (normally -1, 255 in Ubyte) True. It does not always happen, but many times.
If you want to make sure that True is always 1, compile with the flag --strict-bool (More info here: https://zxbasic.readthedocs.io/en/docs/z...ne_Options)