c - Floating point conversion - Binary -> decimal -


here's number i'm working on

1 01110 001 = ____
1 sign bit, 5 exp bits, 3 fraction bits
bias = 15

here's current process, can tell me i'm missing something

  1. convert binary exponent decimal
    01110 = 14
  2. subtract bias
    14 - 15 = -1
  3. multiply fraction bits result
    0.001 * 2^-1 = 0.0001
  4. convert decimal
    .0001 = 1/16

the sign bit 1 result -1/16, given answer -9/16. mind explaining 8 in fraction coming from?

you seem have correct concept, including understanding of excess-n representation, you're missing crucial point.

the 3 bits used encode fractional part of magnitude 001, there implicit 1. preceding fraction bits, full magnitude 1.001, can represented improper fraction 1+1/8 => 9/8.

2^(-1) same 1/(2^1), or 1/2.

9/8 * 1/2 = 9/16. take sign bit account, , arrive @ answer -9/16.


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -