what does this line of code do?

This is a discussion on what does this line of code do? within the C++ Programming forums, part of the General Programming Boards category; What does this line of code do? Code: #define FL_FLY (1<<0); I'm just not sure what the << is for. ...

  1. #1
    Shadow12345
    Guest

    what does this line of code do?

    What does this line of code do?
    Code:
    #define	FL_FLY	(1<<0);
    I'm just not sure what the << is for. If you are wondering its from a game engine, I don't know if that is relevant or not.
    Last edited by Shadow12345; 08-03-2002 at 08:39 PM.

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    >#define FL_FLY (1<<0);

    defines FL_FLY as 1

    the simi colon shouldn't be there though, it could lead to problems, and things like this

    int p = FL_FLY
    note the lack of a semi colon, this makes the code less readable, and more confusing

    and printf("%d", FL_FLY); // is illegal because of the semi colon in the define


    the '<<' shifts the bits to the left the specified number of times in this case '0'.
    do a search for 'bit manipulation', or 'bit shifting', ect...
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  3. #3
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330
    And >> is for right shifting, ~ for negation, ^ for xor, & for and, | for or'ing... etc

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C code line, pointer declaration
    By Dedalus in forum C Programming
    Replies: 2
    Last Post: 06-10-2009, 05:34 AM
  2. help again with scrolling without wrapping
    By Dukefrukem in forum C Programming
    Replies: 8
    Last Post: 09-21-2007, 01:48 PM
  3. Can't figure out a line of code...
    By bamera in forum C++ Programming
    Replies: 1
    Last Post: 10-15-2005, 08:11 PM
  4. SSCANF help
    By mattz in forum C Programming
    Replies: 7
    Last Post: 12-10-2001, 04:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21