Thread: what is "<<"

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    48

    what is "<<"

    Hello

    I was reading a program today and I saw this sign "<<" what does that mean?

    Code:
    x = number / (1 << y);

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    bitwise shift left, i.e. 1 << 3 = 00000001 << 3 = 00001000 = 8; 5 << 2 = 00000101 << 2 = 00010100 = 20.
    Last edited by hk_mp5kpdw; 11-02-2007 at 07:05 AM.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Assuming that "number" and "x" are both integers, I would think that "x >> y" would achieve the same thing, but quicker.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another overloading "<<" problem
    By alphaoide in forum C++ Programming
    Replies: 18
    Last Post: 09-30-2003, 10:32 AM
  2. Overloaded operator "<<"
    By alphaoide in forum C++ Programming
    Replies: 2
    Last Post: 09-27-2003, 07:47 AM