|
Answer» Wonder if anyone could clear something up for me. I'm going through a tutorial sheet from University but it has no answers to check against. One of the questions is 'Convert the following decimal into Little Endian single precision floating point format'
The decimal is -0.000123
The answer i get is
B9 00 F9 80
Thing is, i DOWNLOADED a calculator that claims to do Big and Little Endian, so i can check my answers
http://www.wfwsoftware.com/hexit.html
But this calc gives a different answer - B9 00 F9 90 - one digit difference I checked my answers three times and i still get the same outcome, if the calculator is right then i cant see where i've GONE wrong. Can any one confirm my answer. ThanksI get:
90 F9 00 B9.
the second answer you got from the calc was in Big-endian format; your's, well, I don't know.
Mine uses IEEE 32-bit floating point.
http://en.wikipedia.org/wiki/Single_precision
Yeah, thats right, you got to reverse it for Little Endian.
This is what i've been taught, I have to work it out by hand for forthcoming tests. No calculators allowed.
I got 1 for the sign (obviously, because of the negative value)
0.00000000000010000000111110011000 is 0.000123 in binary
then to 1.0000000111110011000 X 2^-13
remove the first 1 and decimal point and 'pad out' to 23 bit by adding 0's the the end
So 00000001111100110000000
then -13 - -127 = -13+127 = 127-13 = 114
So, 144= 01110010 for the exponent
bring it all together
Sign 1 exponent 01110010 and mantissa 00000001111100110000000
which is 10111001000000001111100110000000
split into groups of 4 to convert to hex
1011 / 1001 / 0000 / 0000 / 1111 / 1001 / 1000 / 0000
Which makes B 9 0 0 F 9 8 0
Then group and reverse 80 F9 00 B9
Can you see anywhere that i've gone wrong, cuz i still cant see it. Oh yeah, thanks for the reply. I think IVE sussed it
0.000123 is 0.00000000000010000000111110011001
and not 0.00000000000010000000111110011000
Thats the difference, that last digit will turn the 8 to a 9
It amazes me that i was attempting to work this out for hours, then 15 mins after my second post and i spot the mistake. Strange how these thing happen!
Quote from: reddevilggg on February 04, 2011, 12:08:51 AM It amazes me that i was attempting to work this out for hours, then 15 mins after my second post and i spot the mistake. Strange how these thing happen!
It happens, at least you got it sorted out.
|