M
Madhur
I am having the following problem of bit shifting.
My program runs on a little endian machine. Consider that if I have
the following data represented in big endian...
0x12345678
the little endian representation would be
0x78563412.
Now if I wan to shift my original data by 4 bits to 0x01234567, then
my approach would be
val = 0x12345678
htonl(htonl(val)>>4)
and result represented in my machine is
0x67452301.
This looks quite redundant to convert little endian to Bid Endian
shift it and then convert back. Basically I thinking of how to get rid
of those two htonl system calls.
I would like to know is there any better way to do this. A best
possibility to shift in little endian mode??
My program runs on a little endian machine. Consider that if I have
the following data represented in big endian...
0x12345678
the little endian representation would be
0x78563412.
Now if I wan to shift my original data by 4 bits to 0x01234567, then
my approach would be
val = 0x12345678
htonl(htonl(val)>>4)
and result represented in my machine is
0x67452301.
This looks quite redundant to convert little endian to Bid Endian
shift it and then convert back. Basically I thinking of how to get rid
of those two htonl system calls.
I would like to know is there any better way to do this. A best
possibility to shift in little endian mode??