1

Background : I am a freshman. I just entered college 3 weeks ago and one of the topic is about numbers. We learn about decimals, binary, hexadecimal, octal, floating point, and so on.

In floating point, the professor explained that the float is stored at 32 bits. With the following specs.

1 bit - sign

7 bits - the exponent(excess 31) (bias)

24 bits - fraction

For example if we're looking at

0 0000001 000000000000000000000001

Then:

Sign -> 0 is positive

Exponent -> 1-31 = 2^(-30)

So the result is

1.000000000000000000000001 x 2^(-30)

correct?

My question:

  1. At one point, something should translate the binary to decimals right? How do the computer store the decimals behind the floating point.

I mean, if I were the programmer, I would create an array of 256 numbers to store the number behind the decimal point. 0 to 9 only takes 4 bits.

  1. If my if-I-were-a-programmer is correct, then why floating precission error comes at a very early place? I mean, given the existance of irrational number, there's no question that a precission error should come somewhere, but I would expect floating precession error comes at 256th number behind coma.

  2. Can you recommend extra reading material on this topic?

I tried to read this, it talks about error of summation (understandable), the conversion, but didn't really talk about the program who did the conversion. Is this compiler specific?

Thanks =D

Realdeo
  • 449
  • 6
  • 19
  • 1
    That's an unusual format. In particular, a 7-bit exponent and an excess of 31 gives a rather unbalanced dynamic range. For question 3, look at the [wikipedia article](https://en.wikipedia.org/wiki/Single-precision_floating-point_format) on IEEE 754 single precision floating-point, but bear in mind that it doesn't quite match what you describe above. (I half suspect that your professor actually meant to introduce IEEE 754 single precision, but garbled the specs somehow.) – Mark Dickinson Sep 19 '16 at 17:43
  • IEEE 754 conformant floats would have 1 sign bit, 8 exponent bits and 23 (24 if you count the -- not stored -- hidden bit) bits of significand. The exponent has a bias of 127, which makes for a rather balanced range. Why your professor uses a slightly differing format is beyond me. – Rudy Velthuis Sep 19 '16 at 20:45
  • Take a look at this post: http://stackoverflow.com/questions/6910115/how-to-represent-float-number-in-memory-in-c/6911412#6911412 . It explains -- in simple words -- how the value 5.2 is converted to a float. – Rudy Velthuis Sep 19 '16 at 20:48
  • I think I miswritten the specs on my note =/ – Realdeo Sep 20 '16 at 09:37

0 Answers0