prev up next   top/contents search

comp.lang.c FAQ list · Question 20.21a

Q: Does C have circular shift operators?


A: No. (Part of the reason why is that the sizes of C's types aren't precisely defined--see question 1.2--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 */


prev up next   contents search
about this FAQ list   about eskimo   search   feedback   copyright

Hosted by Eskimo North