简体   繁体   中英

How to merge 4 unsigned char array elements in one hex value?

I have an array of 4 elements of type unsigned char. How to merge these in one hex value? I need to convert this value to IEE754 value.

eg unsigned char arr[]={0x41,0xD9,0xD4,0x03}

expected o/p : 0x41D9D403

unsigned long hex_val = ((unsigned long)arr[0] << 24) | ((unsigned long)arr[1] << 16) | ((unsigned long)arr[2] << 8) | ((unsigned long)arr[3]);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM