Mail Archives: djgpp/2001/10/18/21:28:34
> Please read a good Boolean algebra book to see that there really is
> no difference between "logical" AND/OR and "bit" AND/OR.
Except DJGPP doesn't compile good boolean algebra books, it compiles C
(well, and other languages). In C, logical and bitwise operators are
different.
0x52 && 0x1f => 1
0x52 & 0x1f => 0x12
The difference is whether the individual bits of the value are handled
independently, or if the whole value is treated as a single boolean
(zero vs non-zero). Try and see:
int main()
{
printf("&& %d\n", 0x52 && 0x1f);
printf("& %d\n", 0x52 & 0x1f);
return 0;
}
It's even more significant with certain pairs:
0x0f && 0xf0 => 1
0x0f & 0xf0 => 0
- Raw text -