u are right.. & is bit wise and.. thats wht i said.. && is boolean.. eg a&&b will be zero if either a or b is zero. but go back to ur code.. the line inputport&&0x80 would return 1 too! coz the neither inputport nor 0x80 is 0 so u get the printf ("MSB is 128") running in that too.. try it .. i did :-) u either check a&b for 128 that is the safest way to check what amazes me is why someone is using && .. that to in the code mentioned by Olyeusi. well.. thanks for the same.. a good break from some boring socket code here Alok > -----Original Message----- > From: D Lloyd [SMTP:dan.lloyd@GB.ABB.COM] > Sent: Friday, January 26, 2001 6:16 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: [OT]: quick question on C > > > Hi, > > Have I got the wrong end of the stick, here, or am I correct in saying > that......... > > No: '&' is a bitwise AND, whereas '&&' is boolean AND. > > As in, if a port was read to see if one of 8 lights had been turned on > > InputPort = 0x8E; > if (InputPort & 0x80) (bitwise) > { > // we would get here > printf("MSB set....Someone turned a light on."); > } > > whereas > > InputPort = 0x8E; > if(InputPort && 0x80) > { > // We would not get here! > printf("InputPort is now equal to 128"); > } > > > > Dan > > > > > > (Embedded Alok Dubey @MITVMA.MIT.EDU> > image moved 26/01/2001 12:27 > to file: > pic04797.pcx) > > > > > > Please respond to pic microcontroller discussion list > > Sent by: pic microcontroller discussion list > > > To: PICLIST@MITVMA.MIT.EDU > cc: > Subject: Re: [OT]: quick question on C > > Security Level:? Internal > > > now .. it is not size "and "pass that would be size&pass > this is size&&pass > > Alok > > > -----Original Message----- > > From: D Lloyd [SMTP:dan.lloyd@GB.ABB.COM] > > Sent: Friday, January 26, 2001 5:54 PM > > To: PICLIST@MITVMA.MIT.EDU > > Subject: Re: [OT]: quick question on C > > > > > > Hi, > > > > Its the same as > > > > "for( set initial condition ; termination condition ; iteration > condition > > )", if you like....where the termination condition is met if 'ptr1' is > > less > > than 'size' AND pass is a non zero value. > > > > Dan > > > > > > > > > > (Embedded Oluseyi Odeinde @MITVMA.MIT.EDU> > > image moved 26/01/2001 12:00 > > to file: > > pic13186.pcx) > > > > > > > > > > > > Please respond to pic microcontroller discussion list > > > > Sent by: pic microcontroller discussion list > > > > > > To: PICLIST@MITVMA.MIT.EDU > > cc: > > Subject: Re: [OT]: quick question on C > > > > Security Level:? Internal > > > > > > u lost me there! > > > > Alok Dubey wrote: > > > > > whoops > > > make that a boolean AND of size and pass > > > sorry > > > alok > > > > > > > -----Original Message----- > > > > From: Alok Dubey (OCS-BLRAKS-AVS) > > > > Sent: Friday, January 26, 2001 5:25 PM > > > > To: 'pic microcontroller discussion list' > > > > Subject: RE: [OT]: quick question on C > > > > > > > > i hnk it is a boolean of size and pass which is then compared to > ptr1 > > > > alok > > > > > > > > > > > > -----Original Message----- > > > > From: Oluseyi Odeinde [SMTP:seyi@OCEAN.CF.AC.UK] > > > > Sent: Friday, January 26, 2001 5:15 PM > > > > To: PICLIST@MITVMA.MIT.EDU > > > > Subject: [OT]: quick question on C > > > > > > > > i apologise if this post appears more than once - just > realised > > that > > > > the > > > > 1st time i sent it, my [OT] channel was turned off! > > > > > > > > hello everyone, > > > > > > > > i came across the following 'for' statement in a code: > > > > > > > > for (pass=rx_str[ptr1+1]; ptr1 > > > > > > > i'm curious about about the 'ptr1 statement > > as > > > > i > > > > have never come across a for loop layed out in this way. > > > > 1. is this valid? > > > > 2. if so, is it the same as saying 'ptr1 > > > > > > > TIA > > > > Seyi > > > > > > > > -- > > > > http://www.piclist.com hint: To leave the PICList > > > > mailto:piclist-unsubscribe-request@mitvma.mit.edu > > > > > > > > > > -- > > > http://www.piclist.com hint: To leave the PICList > > > mailto:piclist-unsubscribe-request@mitvma.mit.edu > > > > -- > > > > Seyi Odeinde > > Instrumentation for extreme environments...earth - ocean - space > > Software Development Engineer > > Earth-Ocean Systems > > > > Email: seyi@earth-ocean.com > > Tel: ++44 (0) 2920 875 183 - DL > > ++44 (0) 7799 537 184 - Mobile > > > > "The most exciting phrase to hear in science, the one that heralds new > > discoveries, is not "Eureka!" (I found it!) but "That's funny ..." > > -- Isaac Asimov > > > > -- > > http://www.piclist.com hint: To leave the PICList > > mailto:piclist-unsubscribe-request@mitvma.mit.edu > > > > > > > > << File: pic13186.pcx >> > > -- > http://www.piclist.com hint: To leave the PICList > mailto:piclist-unsubscribe-request@mitvma.mit.edu > > > > << File: pic04797.pcx >> -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu