Get the first 3 bits of a 4bit Hex number

Status
Not open for further replies.

dsupriya

Newbie level 1
Joined
Mar 6, 2009
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,286
I have a 4 bit Hex number. The first 3 (starting from the LSB at right) bits give me the data and the 4th bit gives me the address.

How do I read the data bits separately?
 

easy in C:
data = hexnumber & 0x07; // mask the lowest 3 bits

your next question will be: "how do I read the address bit?":
address = hexnumber >> 3; // shift the address bit to the lowest position, so address will be 0 or 1
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…