|
From: Eric S. <er...@br...> - 2004-06-11 19:20:13
|
Scott wrote:
> I should've written:
> v = ( ((sum ^ a) & (a ^ ~b)) & 0x80) ? 1 : 0;
> Or you can write:
> v = ( ((sum ^ a) & (~a ^ b)) & 0x80) ? 1 : 0;
Both of these verified to match my version.
For code running on a modern processor with a barrel shifter (not a PIC!),
it would probably be more efficient to write it with a shift, as the
compiler might not be smart enough to optimize out the conditional:
v = (((sum ^ a) & (a ^ ~b)) & 0x80) >> 7;
Eric
|