02-05-2007 04:18 PM
02-05-2007 04:36 PM - edited 02-05-2007 04:36 PM
How about this?
In this case 1 means odd, 0 would be even. But you could work with this however you need to. You wouldn't need to do strings and hex bytes and all of that.
Message Edited by Ravens Fan on 02-05-2007 05:40 PM
02-05-2007 05:21 PM - edited 02-05-2007 05:21 PM
Message Edited by Jarrod S. on 02-05-2007 05:26 PM
02-05-2007 05:33 PM - edited 02-05-2007 05:33 PM
Message Edited by Jarrod S. on 02-05-2007 05:33 PM
02-06-2007 09:42 AM
05-22-2018 04:15 AM - edited 05-22-2018 04:20 AM
The simplest is to use the division with "Quotient & Reminder" (numeric tools). You take your number and divide by 2. If the reminder is zero then the number is even, if the reminder is different than zero then the number is odd.
05-22-2018 04:42 AM - edited 05-22-2018 04:46 AM
@Yodo2 wrote:
The simplest is to use the division with "Quotient & Reminder" (numeric tools). You take your number and divide by 2. If the reminder is zero then the number is even, if the reminder is different than zero then the number is odd.
you are right, that this will give you the info about even or odd, but the question was whether the parity is even or odd. in this case, the number of ones in the bit representation of the number.
also this thread is like 10 years old!
05-24-2018 11:15 AM
@RavensFan wrote:
How about this?
In this case 1 means odd, 0 would be even. But you could work with this however you need to. You wouldn't need to do strings and hex bytes and all of that.
Message Edited by Ravens Fan on 02-05-2007 05:40 PM
If only we had an "Xor Array Elements" function, then we could do it like this:
05-25-2021 10:29 PM - edited 05-25-2021 10:33 PM
I was doing a quick search and found this stream. I realize it's a few years old.
I think some of the answers are great. The easiest way, in my opinion, to implement this is to do the following.
05-26-2021 02:03 AM
@toojer wrote:
I was doing a quick search and found this stream. I realize it's a few years old.
I think some of the answers are great. The easiest way, in my opinion, to implement this is to do the following.
Just do an AND 1 and the result is 1 for odds and 0 for evens. 😉 No need to convert the number to a 32 byte array and loop through it.