ok, im trying to write a function that does a "circular shift" i.e: left shifts "a" by "n" positions, where high order bits are introduced as low order bits.
eg:
10000001 circular shift 1 yeild = 00000011
01101011 circular shift 3 yields = 01011011
heres my code so far...it shifts but does set do the circular thing:
#include <stdio.h>
int circular_shift(int a, int n);
int main(void)
{
int num, yeilds;
char numstring[81];
printf("Enter a number:\n");
gets(numstring);
num = atoi(numstring);
printf("Enter the number of shift yields:\n");
gets(numstring);
yeilds = atoi(numstring);
circular_shift(num, yeilds);
getch();
return 0;
}
int circular_shift(int a, int n)
{
int circular, result, i;
result = a << n;
for(i =1; i<= 8; i++)
{
printf("%d", (result & 0x0080) !=0);
result <<=1;
}
}