ieee 754 – dec float to hex

example : 1280 double in hex = 40 94 00 00 00 00 00 00 as hex

1. log2(1280) = log(1280)/log(2) = 10
2. 1023 + 10 = HEX 0x409 (this is the exponent)
3. now the mantisse: 1280 / (2^10) < -1024 = 1.25 4. 1.25 * 2^52 (^23 for float) = 5.629.499.534.213.120 = BIN 1 0100 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 5. remove the 1st 1 (that for mantisse start) so we would have 100 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 = HEX 0x4 0000 0000 0000 6. 2. -> 0x409 < < 36 | 5.-> 0x4 0000 0000 0000 = hex = 40 94 00 00 00 00 00 00

calc: http://babbage.cs.qc.edu/IEEE-754/Decimal.html
example: http://www.wer-weiss-was.de/theme121/article3802216.html


Comments are closed.