1
$\begingroup$

Hi! I have some difficulties understanding how I'm supposed to calculate this 16bit float to base10.

This is something that is coming up on a test so I would be pleased to learn how this is supposed to be done.

The example we got had number 0101010111110000 where first from left is sign bit, next 6bits is exponent and the rest 9bits is mantissa.

The expression is $(-1)^s * 2^{e-b} * 1.m$

I've spent some time reading wikipedia and such, but I just don't get this. I'm very confused since the only examples I bumped into was [1s|5e|10m] (maybe I'm thinking this wrongly in some way or I'm just plainly stupid)

I would also be pleased if I could get an explanation how I transfer base10 decimal like 118.625 to binary float point and that to 16bit float as before [1 sign | 6 exp | 9 mantissa]

Sorry for the inconvenience

/me bows humbly
$\endgroup$
1
$\begingroup$

The raw fields in your number are:

$s = 0$
$e = 101010_2 = 42_{10}$
$m = 111110000_2$

Without knowing the specific format used, we can't be certain what your bit string represents. But if the IEEE conventions are followed, the exponent bias is 31, and the mantissa has an implied leading 1. In this case, the adjusted values are:

$e' = 42_{10}-31_{10} = 11_{10}$
$m' = 1111110000_2$

So the value is $1.11111_2 * 2^{11_{10}} = \dfrac{63_{10}}{32_{10}} * 2^{11_{10}} = 4032_{10}$

$\endgroup$
3
  • $\begingroup$ rustles papers I think the expression is (-1)^s * 2^e-b * 1.m and i think b is bias $\endgroup$ – Mr_Rixa Aug 21 '14 at 19:52
  • $\begingroup$ Very good! Now all you need to tell us is the value of b, and we're good to go. $\endgroup$ – TonyK Aug 21 '14 at 20:46
  • $\begingroup$ I'm fairly sure that b is 2^6/2 -1 = 31, as you already said. $\endgroup$ – Mr_Rixa Aug 22 '14 at 4:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.