Open glinders opened 5 years ago
it's a question of the point of view and the expectation: a) check if the parity is even and then return true b) make the sum of all all bits (including the returned one) even
so dependent if you want "check" or "make" the expectation is different
Yes, I agree but the name of your function doesn't give a clear hint as to what it does and there is no API description either.
I normally add an 'action verb' in the function name to make it clear; is_parity_even(val) or send_pocsag_message(msg).
I completely agree with you!
Function even_parity(uint32_t x) in file src/pocsag.c returns a '1' if parity is odd and a '0' if parity is even.
The name of the function suggests that it returns 'true' (i.e. '1') if parity is even.
Refer to attached source file: parity.zip
Compile and run with: gcc parity.c -o parity && ./parity