Forums Programming Assignment Help Does C have circular shift operators?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1084
    Aakanksha
    Participant

    Does C have circular shift operators?

    #9648
    Aakanksha
    Participant

    No. (Part of the reason why is that the sizes of C’s types aren’t precisely defined—-but a circular shift makes most sense when applied to a word of a particular known size.)

    You can implement a circular shift using two regular shifts and a bitwise OR:

    (x << 13) | (x > >3) /* circular shift left 13 in 16 bits */

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.