mschnell at lumino.de
Mon Dec 15 09:28:05 CET 2014
On 12/14/2014 04:51 PM, Marco van de Voort wrote:
> More importantly, TRUE is generally defined as !FALSE, and vice versa
IMHO, (usually, ubiquitously ) FALSE is defined as a binary zero of
appropriate bit count (hence unambiguously) , while TRUE is defined as
"not FALSE" and hence it's binary representation is an implementation
detail of the compiler and/or the processor the code is compiled for.
(E.g. the 68 K processor can set a variable according to a condition
code. In this instruction It uses all bits zero for FALSE and all bits
one for TRUE. A compiler might or might not follow this paradigm.
A colleague of mine recently had been hit by this fact, as he called a C
function in a DLL by a Delphi program.
In Delphi, TRUE is all bits set while in (Microsoft) C TRUE is "1".
Now, in C (which does not feature a native boolean type, but boolean
operators) a *decent* boolean decision is e.g. "if (a)". But the silly C
programmer did "if (a ==TRUE). Now the boolean variable "a" imported
from Delphi was presumed as FALSE instead of TRUE.
More information about the fpc-devel