Question

http://i.stack.imgur.com/xaP9s.jpg

Referring to the screenshot above as I'm not able to attach screenshot,

I want to convert the Filesize value which is in Hex to a String i.e. human readable format

The actual decimal value is 5.85 MB

While converting, I am not getting the actual value i.e. 5.85

Can any one suggest how do I convert the values.

I have a set of these hex values and want to convert them into a human readable format.

Was it helpful?

Solution

Each pair of hexadecimal numbers represents a byte, while the lowest value bytes are placed to the left:

0x00 ->   0
0xbb -> 187
0x5d ->  93

0*256^0 + 187*256^1 + 93*256^2 + 0*256^3 + 0*256^4 + 0*256^5 + 0*256^6 + 0*256^7 
    = 6142720

6142720 / 1024^2 
    = 5.85815

This storage format is called little-endian: https://en.wikipedia.org/wiki/Little-endian#Little-endian

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top