-1

I have a hexadecimal to float converter in the form of a code by I am unable to understand as to how did they carry out the conversion.

For Ex: If I have a hexadecimal number as : 11433333; the answer I get from that function is: 145.200.

I tried several methods of conversion like these:

http://www.cs.uaf.edu/~cs301/notes/Chapter4/node13.html

http://babbage.cs.qc.edu/IEEE-754/32bit.html

There is something to do with little endian and big endian, but I am not familiar with that. None of these are giving me the output as 145.200. Could anyone explain me a way out of this please?

Cheers in advance.

Neophile
  • 101
  • Which is it, 145.200 or 145.2200? While you're at it, please check whether there's a typo in the hexadecimal number. – joriki Aug 26 '11 at 14:22
  • 145.2200 is a float value that is generated as an output from the function. There is no typo, everything is fine. I get float values from other hexadecimal input as well. – Neophile Aug 26 '11 at 14:36
  • It's bad enough that there's an obvious typo in your question. I don't see why anyone should bother spending time on answering your question if you don't even take the time to check it after the typo has been pointed out to you. – joriki Aug 26 '11 at 14:41
  • Sorry, my bad. It is 145.200. – Neophile Aug 26 '11 at 14:43

1 Answers1

1

The mystery is resolved when you do the conversion the other way around: the IEEE representation of 145.2 is 43 11 33 3316. So some part of your code is getting the byte order mixed up.

joriki
  • 238,052
  • Thanks a lot. I was just going through that. Glad you told me earlier. It saved me a bunch of calculations. :)

    Cheers.

    – Neophile Aug 26 '11 at 14:57
  • IIRC, that's exactly the difference between "little endian" and "big endian". They will switch the order of bytes within a word. – nickalh May 06 '15 at 11:06