Verifying a 3 bit end-around rotation in C++ -


this question has answer here:

i need 3 bit left end around rotation in c++.

so far have:

a[i] = (a[i] << 3)|(a[i] >> 5); 

a unsigned char array.

is correct? if not how can fix it? best way test , see if correct?

thanks

looks fine me.

if want test it, work out bunch of inputs , outputs hand , check program produces them.

or devise method you're absolutely sure produce results (eg convert unsigned char binary string, rotate string, convert unsigned char) , compare 2 against 256 possible inputs.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -