Your constants aren't supposed to be more than 8 bits. Your compiler may still handle it ok, but it's still going to be compiled as something like the following. Besides, it's better for readability to do this as well so someone doesn't have to count all the damn 0's.
Dwindlehop wrote:I'm surprised no one complained that I mixed binary and hexadecimal when initially describing the problem. ::sniff:: I'm so proud of you!
Wow, you're right, totally missed that. As for being proud of crappy debugging skillz, you must be smoking something. Anyways, I blame it on understanding your intent and leaving implementation up to the user (ie. you).
Dwindlehop wrote:I'm surprised no one complained that I mixed binary and hexadecimal when initially describing the problem. ::sniff:: I'm so proud of you!
Wow, you're right, totally missed that. As for being proud of crappy debugging skillz, you must be smoking something. Anyways, I blame it on understanding your intent and leaving implementation up to the user (ie. you).
I think understanding my intent and leaving well enough alone is something we can all be proud of.
ok, you suck. You can't even represent what you want correctly. The new function you wrote barely makes sense in context of what you originally wrote. What you want is a bool essentially? And you want y to be is the xor of those 3 bools? Ok, then what you have now would work most of the time.
There is a bug though. What you don't realize is that >> shifts in x[31]. In most cases you're zeroing out this bit from the bit mask, but if you actually want x[31] and it's 1, you're not going to get what you expect. Completely correct code would be as follows:
Oh, and this is what you get for being proud of us being not overly picky. By trying to understand what you meant, we ignored the complete lack of consistency in your original examples of psuedo-code.
Yes, I want the xor of three bools. In my actual implementation, I'm using unsigned long longs instead of ints. I went ahead and took the least significant bit only, though.