unsigned right shift operator

This is a discussion on unsigned right shift operator within the C Programming forums, part of the General Programming Boards category; Apparently, when I use the unsigned right shift operator (>>>), I receive an error during compilation. I am using MinGW. ...

  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    104

    unsigned right shift operator

    Apparently, when I use the unsigned right shift operator (>>>), I receive an error during compilation.

    I am using MinGW.

    Is this operator not available in C? If so, what would be the equivalent to this?

    Thank you,
    abraham2119

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    There is no >>> in C. If your variable is unsigned, it should happen automatically with >>.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,047
    There is unfortunately no >>> operator in C or C++ (though there is in other languages like Java).

    The >> operator does what you are expecting. On signed integers, the >> may do sign-extension or it may do an unsigned shift, depending on the implementation. For signed integers, if you need one particular behaviour, you can emulate it yourself with other bitwise operators.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 02:07 AM
  2. Replies: 12
    Last Post: 08-11-2008, 11:02 PM
  3. Replies: 16
    Last Post: 10-29-2006, 04:04 AM
  4. operator overloading and dynamic memory program
    By jlmac2001 in forum C++ Programming
    Replies: 3
    Last Post: 04-06-2003, 11:51 PM
  5. ANY BODY WILLING TO HELP ME WITH Microsoft Visual C++
    By BiG pImPiN fOoL in forum C++ Programming
    Replies: 12
    Last Post: 11-04-2001, 05:03 PM

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