Re:The unknown features of Python's `operator` module
by klyrs on Sunday August 08, 2021 @01:58PM
(#28108659)
Can you show me an integer whose parity differs from its least significant bit?
[ Parent
| on HN ]
Re:The unknown features of Python's `operator` module
by mikevin on Sunday August 08, 2021 @04:03PM
(#28109647)
Maybe 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?
Re:The unknown features of Python's `operator` module
by klyrs on Sunday August 08, 2021 @08:27PM
(#28111513)
What 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.
Re:The unknown features of Python's `operator` module
by kazinator on Sunday August 08, 2021 @04:09PM
(#28109689)
Note that these two are different:
https://en.wikipedia.org/wiki/Parity_bit
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.