M
Madhur
I would like to know the best efficient way to shift a flat buffer by
say 4bits.
for exaple if the flat buffer is
0x62 0x48 0x23 ....
then the result should be
0x06 0x24 0x82 0x3.....
byte by byte shifting somehow looked very inefficient.
Something like
int main()
{
unsigned char sample1[50];
unsigned char sample2[50];
int i;
for(i=0; i < 50; i++)
{
sample1 = rand(250);
}
for(i=0 ; i < 50; i++)
{
printf("%02x \n",sample1);
}
printf(" output after shifting\n");
sample2[0] = sample1[0]>>4;
for(i=1; i <= 50; i++)
{
sample2 = (sample1[i-1] << 4) | (sample1>>4);
printf("%02x \n",sample2);
}
return 0;
}
Is there any other best way to do this.
say 4bits.
for exaple if the flat buffer is
0x62 0x48 0x23 ....
then the result should be
0x06 0x24 0x82 0x3.....
byte by byte shifting somehow looked very inefficient.
Something like
int main()
{
unsigned char sample1[50];
unsigned char sample2[50];
int i;
for(i=0; i < 50; i++)
{
sample1 = rand(250);
}
for(i=0 ; i < 50; i++)
{
printf("%02x \n",sample1);
}
printf(" output after shifting\n");
sample2[0] = sample1[0]>>4;
for(i=1; i <= 50; i++)
{
sample2 = (sample1[i-1] << 4) | (sample1>>4);
printf("%02x \n",sample2);
}
return 0;
}
Is there any other best way to do this.