smunaut / osmo-pocsag

POCSAG experiments
GNU Affero General Public License v3.0
27 stars 12 forks source link

Function even_parity is actually odd_parity #1

Open glinders opened 5 years ago

glinders commented 5 years ago

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

nospam2000 commented 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

glinders commented 5 years ago

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).

nospam2000 commented 5 years ago

I completely agree with you!