0

I know a float variable takes up 4 bytes in memory. But I want to know how it is saved? For example, if I define a variable:

float b = 1.0;

And I print the address of b in debugger command line:

enter image description here

Then I watch the value of register in this address enter image description here

I have learned that a float variable has 1 sign bit, 8 enponent bits and 23 mantissa bits. I have watched some different value but I haven't found the law. So I just want to know how a float is saved? What does the value of register mean?Which bit stands for enponent bit and which stands for mantissa bit? Is it saved as a form like A*10^B, and B is enponent and A is mantissa?

Thank you for your answer!

  • 2
    http://en.wikipedia.org/wiki/Single-precision_floating-point_format – Peter Apr 16 '15 at 01:46
  • 6
    C does not require any specific representation for values of type `float` or any other type. It just places a few constraints, and lets implementations choose. They can, and historically have, made different choices. With that said, these days [IEEE single-precision floating-point format](http://en.wikipedia.org/wiki/Single-precision_floating-point_format) is the *de facto* standard. – John Bollinger Apr 16 '15 at 01:46
  • http://en.wikipedia.org/wiki/IEEE_floating_point – Ôrel Apr 16 '15 at 01:48
  • http://programmers.stackexchange.com/questions/215065/can-anyone-explain-representation-of-float-in-memory – Sir Jo Black Apr 16 '15 at 01:51
  • http://steve.hollasch.net/cgindex/coding/ieeefloat.html – Sir Jo Black Apr 16 '15 at 01:55

0 Answers0