Could somebody explain to me how I convert the hex values [3c][f7][3][0] to the number 259900 please? I know it has something to do with little endian but I can't figure it out.
Many thanks
Could somebody explain to me how I convert the hex values [3c][f7][3][0] to the number 259900 please? I know it has something to do with little endian but I can't figure it out.
Many thanks
0x0003f73c = 259900, so just reverse the bytes. How to reverse the bytes depends on the format (data type) of the 4 bytes. Where is the data coming from? How is the data stored?
If these are 4 separate bytes you'll have to create a new type-long variable (and maybe some temporary type-longs) , and use [u]bit shifting[/u] (and maybe a bitwise OR) to re-assemble the bytes.
Once you have the bits in the correct order, you'll have a normal integer variable stored in binary and C++ will automatically convert it to decimal by-default when you "print" it out.
P.S.
Little endian is normally related to file storage on a disk (or thumb drive, etc.). If you read/write an integer with the regular C++ commands the byte-order is taken care of automatically and you don't have to worry about it. But if you read the bytes instead of reading the variable "normally" you have to be aware of the byte-order.
DVDdoug:
P.S.
Little endian is normally related to file storage on a disk (or thumb drive, etc.). If you read/write an integer with the regular C++ commands the byte-order is taken care of automatically and you don't have to worry about it. But if you read the bytes instead of reading the variable "normally" you have to be aware of the byte-order.
Mainly memory, not file storage. Some processors (like PPC) can even change endianness.