Rotate Left

S

Shawn B.

Greetings,

I'm performing a Rotate Left like this:

return ((it << val) | (it >> 32 - val));


The problem is, I can only make it work if "it" is 32-bit or 64-bit. I need
it to work with 8 and 16 bit as well. So, how can I simulate an 8-bit
rotate with a 32-bit value (or 16-bit rotate with 32-bit value)? BTW: This
is a managed C++ project.


Thanks,
Shawn
 
S

Stefan Slapeta

Just be careful about using an unsigned type (not 'int'!)

The rest should work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top