CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

AND-operator

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jjude



Joined: 12 Nov 2007
Posts: 37

View user's profile Send private message

AND-operator
PostPosted: Mon Nov 19, 2007 8:04 am     Reply with quote

I read port B value=input_b();
I need only LSB-bit in B-port.
How i can work AND-operator?

This: value=input_b()&0x0f
or value=input_b()&&0x0f
or how???
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Mon Nov 19, 2007 8:35 am     Reply with quote

The very best way to find out is to write a short test program using both and look at the assembly code generated.

The second best way is to look in a C primer book and read the differences between Logical AND and Bitwise AND.

The least best way is to ask here and have someone you don't know simply tell you that you should use value=input_b()&0x0f for the least significant nibble or value=input_b()&0x01 for the least significant bit.
_________________
The search for better is endless. Instead simply find very good and get the job done.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Nov 19, 2007 8:45 am     Reply with quote

I totally agree with SherpaDoug and would like to insert a third option, i.e. before asking on this forum:
3) Read the manual and study all available commands. Just so you know which commands and helper functions exist (you might have stumbled upon the bit_test() function).
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group