2 ms·
Can you show me an integer whose parity differs from its least significant bit?
by klyrs 5y ago
Can you show me an integer whose parity differs from its least significant bit?
- mikevin 5y agoMaybe a stupid question but I've never learned much about parity and this sounds like a good opportunity. Can you give some definitions? Are you talking about error checking parity or 'evenness' parity? I'm guessing the last one since that's what fits your LSB comment(when using 'evenness' not 'oddness'). But in that case I'm not sure your example is doing, my python might be too rusty but is it something like: get the unicode representation(int) of each character in a string, xor the results and get the LSB?
- klyrs 5y agoWhat I meant by parity was 'evenness' -- but the ultimate purpose was to explain the utility of the xor function provided by the operator module. But, the more useful concept is parity for error detection, which my example clearly fails at.
- kazinator 5y agoNote that these two are different: https://en.wikipedia.org/wiki/Parity_bit https://en.wikipedia.org/wiki/Parity_bit https://en.wikipedia.org/wiki/Parity_(mathematics) https://en.wikipedia.org/wiki/Parity_(mathematics) "parity check on a string" tends toward the former interpretation of "parity". You don't do parity checks by looking at only the least significant bit of every code word.
- klyrs 5y agoAh, I understand now. You're right, an actual parity check should reduce the bits of the final result.