LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-20-2004, 05:24 AM   #1
blackzone
Member
 
Registered: Jun 2004
Posts: 256

Rep: Reputation: 30
checking bit of an address


how do I check if a bit in a data structure is set or not.

for example I have a 8 bit char

is there a direct function which let you check if bit 1 and bit 3 is set?
 
Old 09-20-2004, 05:31 AM   #2
Proud
Senior Member
 
Registered: Dec 2002
Location: England
Distribution: Used to use Mandrake/Mandriva
Posts: 2,794

Rep: Reputation: 116Reputation: 116
Masking, eg and the byte with 00001010 and check the result equals 00001010?
 
Old 09-20-2004, 06:35 AM   #3
bahramH
Member
 
Registered: Apr 2004
Location: France
Distribution: Mandrake
Posts: 67

Rep: Reputation: 15
To do binary "AND" (between respective bits of two chars
for example) use "&".
 
Old 09-20-2004, 09:39 AM   #4
jwstric2
Member
 
Registered: Jan 2004
Posts: 105

Rep: Reputation: 15
#define CHECK_BIT(s, b) ((s[b/8] & (1 << ( b%8)))!= 0)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get ip address, broadcast address, mac address of a machine sumeshstar Programming 2 03-12-2005 04:33 AM
36 bit memory address Schmidt Programming 2 03-03-2005 01:45 AM
checking ip address??? I_luv_linux Linux - Networking 2 11-01-2004 11:56 AM
How to detect the address bit from a protocol. vedion Linux - Software 0 04-30-2004 05:35 AM
Why 32-bit for IP Address? velan Linux - Wireless Networking 6 04-19-2004 02:46 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration