Thread: C# bitwise operations.

  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    68

    C# bitwise operations.

    In the code
    Code:
    UInt64 mask = (UInt64)((message[4] << 48) | (message[5] << 40) | (message[6] << 32) | (message[7] << 24) |
                                      (message[8] << 16) | (message[9] << 8) | message[10]);
    
    for (UInt64 i = 0; i < 64; i++)
    {
        UInt64 c = mask & ((UInt64)(1) << i);
    }
    I get
    Error CS0019 Operator '<<' cannot be applied to operands of type 'ulong' and 'ulong'

    Should I split UInt64 for two UInt32 or is there any way around?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > Should I split UInt64 for two UInt32 or is there any way around?

    > for (UInt64 i = 0; i < 64; i++)
    Overkill much?
    You can count to 64 in a byte ffs.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bitwise Operations Help Please!
    By workisnotfun in forum C Programming
    Replies: 2
    Last Post: 11-19-2012, 10:22 AM
  2. Bitwise Operations
    By drkidd22 in forum C Programming
    Replies: 2
    Last Post: 11-12-2009, 11:09 PM
  3. bitwise operations
    By black_watch in forum C++ Programming
    Replies: 7
    Last Post: 03-23-2007, 03:01 PM
  4. bitwise operations
    By barneygumble742 in forum C Programming
    Replies: 10
    Last Post: 09-11-2004, 10:33 AM
  5. bitwise operations in C
    By samps005 in forum C Programming
    Replies: 5
    Last Post: 10-10-2002, 03:35 PM

Tags for this Thread