简体   繁体   中英

Convert the following 32 bit binary numbers represented in IEEE floating point (S, Fraction ,Exponent) to decimal number

0 00000000000000000000000 0111011

How would I do this problem I am lost.

Your bolding suggests that you might be a bit confused about the order of fields; IEEE generally uses the order sign,exponent,fraction for floating point numbers. (Incidentally, this allows the use of twos-complement-integer sorts to sort IEEE floating point numbers, if there are no NaNs or other non-numeric values.)

So what are we looking at here? The first bit is the sign: 0. So we have a positive number. (How to remember this? Go back to the allowed-to-use-integer-sort -- a leading one in a twos-complement integer means it's negative.)

The next eight bits are the exponent: also 0. This is the lowest possible exponent value; it normally represents an unsigned integer biased by 127, or the value -127. However, the exponent value 0 is reserved for encoding subnormal numbers (numbers less than the smallest normally representable); in this special case, the effective exponent is -126, but rather than representing the number 1.fraction * 2^exponent, a subnormal represents the number 0.fraction * 2^exponent.

Finally, we have the fraction, which is 0000000000000000111011 . So our total number is 0.0000000000000000111011b * 2^-126. Converting this to decimal is left to the reader.

I agree with @addaon's previously posted answer. In addition, the conversion can be done easily in some languages, including Java:

public class Test {
   public static void main(String[] unused) {
      int raw = 0b0000000000000000000000000111011;
      float f = Float.intBitsToFloat(raw);
      System.out.println(f);
   }
} 

(You need version 7 to get the binary literal, but the same thing can be done a little less directly in earlier versions)

The output is 8.3E-44, consistent with interpretation as a positive denormalized number, and with the conversion web site.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM