Thread: Circular Bit Shifts

  1. #1

    Circular Bit Shifts

    Is it possible to do a circular bit shift in c++?

    10001000 => 00010001 => 00100010 => 01000100

    GCC on Red Hat 8.1 (Primary)
    GCC on Mac OS X 10.2.4 (Secondary)

    MinGW on XP

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    char RotateLeft(char Byte)
       return (char)((Byte << 1) | (Byte >> 7));
    I believe there is a "rotate" asm instruction that does this too...
    Not sure if a C/C++ function does it though.

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Comment your source code! Lynux-Penguin's Avatar
    Join Date
    Apr 2002
    not by any standard means, you could write a class to handle binary numbers and do it yourself. Or write a function that does a circular bit shift.

    Asking the right question is sometimes more important than knowing the answer.
    Please read the FAQ
    C Reference Card (A MUST!)
    Pointers and Memory
    The Essentials
    CString lib

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bit processing in C
    By eliomancini in forum C Programming
    Replies: 8
    Last Post: 06-07-2005, 10:54 AM
  2. Bit shifts
    By Buckshot in forum C++ Programming
    Replies: 13
    Last Post: 05-23-2005, 08:14 PM
  3. Porting from 32 bit machine to 64 bit machine!
    By anoopks in forum C Programming
    Replies: 10
    Last Post: 02-25-2005, 08:02 PM
  4. circular shift
    By n00bcodezor in forum C Programming
    Replies: 2
    Last Post: 11-20-2001, 03:51 AM
  5. Array of boolean
    By DMaxJ in forum C++ Programming
    Replies: 11
    Last Post: 10-25-2001, 11:45 PM