LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 12-11-2005, 10:36 PM   #1
Bluesuperman
Member
 
Registered: Nov 2002
Distribution: Slackware
Posts: 155

Rep: Reputation: 30
C code if (get_le_long(buf + 96) & 0x0008) ???


Hello,

I do not understand the following piece of code:

if (get_le_long(buf + 96) & 0x0008)

What does the "&" do ? I believe get_le_long retrieves 96 bytes from buf ? But is the "&" active like a place holder ?

Thanks

Michael
 
Old 12-11-2005, 11:36 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
"get_le_long()" returns the little-endian 32-bit integer long that it finds at network buffer position "buf+96".

The "&" is the C bitwise "and" operator.

Let's say the value at buf+96 is "6". The value will be:

0x0000 0006
& 0x0000 0008
-----------
0000 0000

Why?
decimal(6) = binary(0110)
decimal(8) = binary(1000)

Left-to-right:
0 AND 1 = 0
1 AND 0 = 0
1 AND 0 = 0
0 AND 0 = 0
 
  


Reply



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
../video-buf-dvb.h:2:20: error: dvbdev.h: No such file or directory laurentwahl Linux - Hardware 0 10-30-2005 01:09 PM
ndiswrapper: couldn't allocate dma buf SAM_Juan1234 Linux - Wireless Networking 0 09-14-2005 01:03 PM
User Preferences: Use HTML code instead of vB code? (vB code is overrated) stefanlasiewski LQ Suggestions & Feedback 5 07-26-2005 01:37 AM
hdparm error -> could not allocate sharedmem buf: Function not implemented Adony Linux - Software 1 12-02-2004 02:06 PM
haming code & java or C++ dilberim82 Programming 5 02-03-2004 06:58 PM

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

All times are GMT -5. The time now is 04:33 PM.

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