"Chris Dollin" <ch**********@hp.comwrote in message
news:e9**********@malatesta.hpl.hp.com...
Thad Smith wrote:
>sonos wrote:
>>I hope this is the right usenet group for posting this code...
IF (PORTA & 0x03 == 0x03) ...
.. I want to verify if PORTA (0x00 to 0xFF) has bit 1 and bit 2 set to
1.
Is this the proper code?
No. "if" must be lowercase. You must parenthesize to get the operation
you want:
if ((PORTA & 0x03) == 0x03) ...
And you don't /need/ to write the number in hex:
if ((PORTA & 3) == 3) ...
although your style may prefer it (especially if there are wider
bit-patterns
around).
The OP said:
I want to verify if PORTA (0x00 to 0xFF) has bit 1 and bit 2 set to 1.
One could imply from this that the correct answer would be:
if ( PORTA & 3 ) ...
because the OP did not specify that ONLY bits 1 and 2 must be set.
>
--
Chris "seeker" Dollin
A rock is not a fact. A rock is a rock.
--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Software Reuse Project