Understanding Probleme

Feb 13, 2006 6 Replies

Hi,



i have a little prob to understand this :



if( pir1 & (1


Well, at the risk of doing your homework for you....

if (variable) pir1 BITWISE AND with [1 (shifted left) by the number of bits specified in the (constant or variable) SSPIF] evaluates true (i.e. the appropriate bit in pir1 is set), then execute code

Somewhat like

#define MASKBIT 0x4 a = 0x10;

if(a & (1

would that be his English homework .....

Snort

I must admit the readability of some posts is less than others

Cheers

PeteS

thanks for the Answer ! So the code would always run ?

if I good undestand, it will be the same as :

if (SSPIF == 1) { Code }

It is right ?

Thanks

Chris

Not really. If the bit position specified in SSPIF is set in the variable, the code will run, otherwise not.

This is a common piece of code to determine if a particular bit is set in some variable and run some code if so, and perhaps some other code if not.

Consider a typical short;

short bitflags;

#define b15position 15; // number of shifts to move a one to the bit 15 position

// .. do some manipulation of bitflags

if(bitflags & (1

You bad understand. If think you this same as before is. It is wrong.

Look up "shift left" for starters.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required