I didn't know it has that bug. But that's probably I rarely need to convert
an integer to boolean, and back to integer. Mostly I just do it like this.
writeln(ord(x = 0)); //for writeln(integer(not boolean(x)));
No it doesn't. The problem occurs when typecasting a variable. Typecasting a
constant won't have that problem.
> // it was just an illusion lol ! ;) Delphi probably optimized the constants
> above ! ;) :)
That's not the problem too, IMO. The code optimization compiler directive
doesn't affect this problem. The problem seems to be in the compiler itself.
i.e. how it handles and compiles typecasted variable/constant.
Whe I see it at assembly level, boolean-typecast doesn't actually convert
the value to either 0 or 1. And if the value is a variable, boolean
operators will be performed only on the least significant bit of the value
(bit 0). So, a "not boolean(x)" will simply be "boolean(x xor 1)".