Float is stored in memory in the form of:
Let's look at the following example:
float *p = (float *) #
printf ( "num=%d\n", num);
printf ( "*p=%d\n", *p);
*p = 5.0;
printf ( "num=%d\n", num);
printf ( "*p=%f\n", *p);
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7E/D4/wKiom1cJs0Hh-sUSAABjTlfWUhg718.png "title=" Untitled. png "alt=" Wkiom1cjs0hh-susaabjtlfwuhg718.png "/>
This is because the storage format of float in the computer is different from the format of the int storage:
For float type:
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/7E/D4/wKiom1cJs1WyJW78AABzZ65NSkk127.png "title=" Float.png "alt=" Wkiom1cjs1wyjw78aabzz65nskk127.png "/>
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>
For example: 5.0 (101) in memory is stored in the form of
5.0 = (-1) ^0* (1.01) *2^2
0 10000010 01000000000000000000000
Is it strange to point to digital e? Because e occupies 8 bit bits, the value range is 0-255, not the negative number, so we give E plus a 127 and then save to the decimal point. This will allow you to take
Negative. When we read this, we can subtract 127 from E.
When e is full 0 o'clock, it represents a number close to 0, because E is full 0 o'clock, M will no longer add 1,m to 0.xxxxxxx ... , the index of the floating-point number is 1-127, which is a non-long-small count.
When e is full 1 o'clock, if M is full 0, it represents a number of positive and negative infinity.
Now, for the example above, it is clear that the same number is seen in the form of float and int, and the results are different.
For double form, it is the same, except double is 8 bytes, 64 bit bit, so the double exponent is 11 bits (to add a 1023), the valid bit is 52 bits.
This article is from the "11132019" blog, please be sure to keep this source http://11142019.blog.51cto.com/11132019/1762252
The storage form of floating-point numbers