LinuxQuestions.org
Visit Jeremy's Blog.
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 08-15-2005, 05:56 AM   #1
ewt3y
Member
 
Registered: May 2005
Location: hanoi vietnam
Distribution: mandriva
Posts: 106

Rep: Reputation: 15
C << /


#define COMPAT_VERSION_MAJOR 3
#define COMPAT_VERSION_MINOR 2
#define COMPAT_VERSION ((COMPAT_VERSION_MINOR << 8) \
| COMPAT_VERSION_MAJOR)


Plz explain what << 8 and \ mean ?
 
Old 08-15-2005, 06:15 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Re: C << /

Quote:
Originally posted by ewt3y
#define COMPAT_VERSION ((COMPAT_VERSION_MINOR << 8) \
| COMPAT_VERSION_MAJOR)

Plz explain what << 8 and \ mean ?
"<<" is one of C's bitwise operators. They are used to fiddle with the actual bits (ones and zeroes).
"x << 8" means: "take x, and shift its bits 8 bit-positions to the left. (8 bits == 1 byte). So "x << 8" is equivalent to multiplying by 256. Likewise "6 << 1" evaluates to 12 (the bits of 6 == 00000110 are shifted one bit-position to the left: 00001100, which is 12).

Example:
Say x == 254(decinal) == FE(hexadecimal) == 11111110(bin).
Then (x << 8) will be: 1111111000000000(bin) == FE00(hex) == 65024(dec).

Th \ just "escapes" the newline following it, so the compiler will consider the two lines as one. Example:

printf("hello \
there");

will be processed by the compiler as if it were:

printf("hello there");

Last edited by Hko; 08-15-2005 at 05:50 PM.
 
  


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



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

All times are GMT -5. The time now is 09:26 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