I am not quite sure about this code.

I seem to have some problem understanding what the result should look like.

If I input a base-10 number like

1028

that should yield a binary number

10000000000

(2 ^10)

Right??

in hex that would be 0000 0100 0000 0000 Right?

The largest base-10 to binary number would be

less than 100000

So how come my answer is showing after a shift a number bigger than 100000???

Forgive my stupidity. This is by far the hardest thing I have tried to imagine, since my brain is used to base-10 format of numbers. Been a very long time that I talked in binary.

here's what I got now:

Code:

#include <stdio.h>
unsigned int rotate_left(unsigned int i, int n);
main()
{
int number,shifter;
int i;
printf ("Enter integers and a value to shift them to "
"the left by (separaated by single space): ");
scanf("%d %d",&number,&shifter);
printf("Your original number was %d\n"
"And it was shifted %d places to the left\n",
number,shifter);
i=rotate_left(number,shifter);
printf("\nNow results in the number %d \n\n",i);
return 0;
}
unsigned int rotate_left(unsigned int i, int n)
{
int mask;
for (mask = 0x8000; mask != 0; mask >>=1)
{
if (mask & i) printf ("1");
else printf ("0");
}
return ( (i << n) | (i >> ((sizeof(int)*8)-n)) );
}