Rotations of bitfield or 'circular shifts' are very often used in cryptography as an non-linear operator to achieve what they call 'confusion' (trying to break all the statistical links between the clear-text and the cipher-text).
The classical graphical representation of the rotation-left is quite self explanatory:
But, it also has a meaning in pure arithmetic. It can be seen as a multiplication and an addition like that (
n is the size of the bitfield):
rotate-left (a, 0) = a
rotate-left (a, 1) = 2^(1).a + 2^(-n).a
rotate-left (a, 2) = 2^(2).a + 2^(1-n).a
rotate-left (a, n-1) = 2^(n-1).a + 2^(-1).a
rotate-left (a, n) = a
In C language you might interpret this with only bitwise operators as follow (see the Wikipedia article about circular shift):
uint32_t rotl32 (uint32_t value, unsigned int count)
return ((value << count) | (value >> (32 - count)));
Anyway, the rotations are often neglected in most of the programming languages. You cannot find it easily in C for example. But, this is mainly because:
- Only cryptography is using it (and few other very low-level domains).
- It can be implemented as a function with the provided operators (it does not increase the expressive power of the language to add it to the language).
Yet, all the assembler languages propose rotations operators because they can be source of a lot of optimizations at low-level.