Little Endian to Big Endian for 32 bit

I

invincible

Regarding 16bit signed integer ,
its working out fine. Thanks a lot . But I have similiar problem with 32 bit
signed integer. Kindly help me out

I have used
((s32Val << 24) | (s32Val >> 24) | ((s32Val >> 8)& 65280)
| ((s32Val << 8)& 16711680))

But it is not working with 32 bit signed integer

Thanks for help
 
R

red floyd

invincible said:
Regarding 16bit signed integer ,
its working out fine. Thanks a lot . But I have similiar problem with 32 bit
signed integer. Kindly help me out

I have used
((s32Val << 24) | (s32Val >> 24) | ((s32Val >> 8)& 65280)
| ((s32Val << 8)& 16711680))

But it is not working with 32 bit signed integer
The right shift by 24 (second expression) should be "anded" with 255.
Since you say "s32Val", I'm assuming you're signed, so the right-shift
by 24 gets sign-extended.

Incidentally, I'd recommend using hex constants to make it more obvious
what you're doing, instead of the decimal ones.

i.e.: 65280 = 0xff00, 16711680 = 0xff0000, 255 = 0xff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,831
Latest member
HealthSmartketoReviews

Latest Threads

Top