3 ms·
Because booleans are not 1-bit integers. They're not integers at all. The only thing computers represent directly are ones and zeros. 1 and 0 are not integers
by dreamcompiler 3y ago
Because booleans are not 1-bit integers. They're not integers at all.
The only thing computers represent directly are ones and zeros. 1 and 0 are not integers either; they're just high or low voltage levels on wires. The fact that we label them "1" and "0" is just for convenience; it doesn't make them integers.
Even addition itself is an abstraction. As far as the CPU is concerned, addition is just a multi-bit XOR operation coupled with some AND operations.
We abstract sets of 1s and 0s to mean numbers, pointers, characters, booleans, symbols, arrays, structures, etc. and we abstract operations on them as well. If we don't make our abstractions explicit, we cannot reason about what results to expect from a computer's operations, nor can we enlist computers to help us with that reasoning process.
By your argument I might as well add integers to strings or arrays or structures -- they're all just bits after all. We might as well not have types at all and just let the programmer keep track of all operations manually. That's assembler programming and it's extremely bug-prone and it doesn't scale.
- account42 3y agoThe ring ({false,true},xor,and) is isomorphic to ℤ₂ aka the 1-bit integers. Deal with it.