In C language there are two shift operators, whose names are shift left (<<) and shift right (>>). Here we study the two shift operators. The two operator are intrinsic instruction of C language, and they are not part of any library. The program here attempts to show how the shift operators actually work. We are able to predict the outcomes of the operators without actually running a program. Here are the cases demonstrated in the program which may be download from this page. All cases are care demonstrated in this program using both operators << and >>.
Data types tested:
Unsigned integer
Positive signed integer
Negative signed integer
The most intriguing case is that of an signed negative integer being shifted to the right. All other cases are rather straightforward.
Available for download: