Posted by: blackcat (Paul) on board 'ee'
Date: Sat Apr 16 19:02:43 1994
Title: float and double formats of IEEE Standard Signature
Posted by: Alexander (Small Partition)
Date: Sat Apr 16 17:13:00 1994
Title: float and double format of IEEE Standard license.
Some people have asked questions about the memory formats of float and double types in the C statement, so I am
In this article, I will refer to what I know. If you have any website, please give me more advice...
Description of floating point data format developed by IEEE:
Float memory: 4 bytes are stored, that is, 32 bits.
The usage of each bit is as follows:
Bit 31 23 ~ 30 0 ~ 22
── ┬ ── ─ ┐
│ 正│ │ bottom data │
── ┴ ── ─ ┘
Double type memory: it is saved with 8 bytes, that is, 64 bits.
The usage of each bit is as follows:
Bit 63 52 ~ 62 0 ~ 51
── ┬ ── ─ ┐
│ 正│ │ bottom data │
── ┴ ── ─ ┘
Positive Direction direction (sign): 1 is positive, 0 is positive.
Exponential: returns the base number after the power of 2.
Note: In float, because there are 8 bits, there are 2
The power of 256, but because the data can be exactly the same, the IEEE stipulates that this process is
To the power of data output, We need to extract 127 to the power of data. Therefore, float data can be retrieved from
-126 to 128.
Similarly, the double type has 11 bits, and the calculated value must be 1023, so
The double value ranges from-1022 to 1024.
Mantissa: the format of this part is actually plain in text,
Please refer to the following example.
0 because it cannot be expressed by any 2's power, so the 0 representation is
Float: 00 00 00
Double: 00 00 00 00 00 00 00 00
Calculate 17.625 bytes as a float type.
First, calculate the 17.625 percentile as 2.
(What ?? How did I use small data ?? Okay, I want to tell you, because
0.625 = 0.5 + 0.125, 0.5 is 1/2, 0.125 is 1/8, so
The 2nd percentile is 0.625. If you do not understand it, please ask another question.
Man. Of course, the data here is so perfect that it is easy to understand,
In fact, the small part of the plot is out with infinite approximation .)
Then shift 10001.101 to the right until there is only one (this one
When the number is 1), it becomes 4 to the power of 1.0001101x2 (because it is shifted to the right
4 digits). At this time, the bottom data and indicators we want come out: the bottom data, because it is small.
Before the data point, it must be 1. Therefore, IEEE rules only record the small data point.
The base number of the question is 0001101. It indicates that the part of the question is actually 4, but it must be added in the format
127, fixed as 131, that is, 10000011 of binary.
Merge the upper columns of each shard. The float Memory Format of 17.625 is:
0 10000011 00011010000000000000000
Bytes bytes into byte: 41 8d 00 00
In addition, because the Intel CPU is little endian
41 8d 00 00 in the memory is placed in the order of 00 00 8d 41. (Address
From low to high)
All the above materials can be verified using the watch function in the Borland C ++ IDE environment.
Coming out.
Additional information: Computer Organization (3rd ed.) p.304 ~ P.306
McGraw-Hill Int 'l
Authors: v. Carl Hamacher
Zvonko G. vranesic
Safwat G. zaky
Finally, I hope you can understand this article and may ask questions.
Managers are directed to the refined area of the EE board, so that I can keep a long name
I also hope that the old readers will see it again. In the course of hard work, I will add more points to my score and my learning skills.
It's 8031xxx (ah !! To ensure the safety of my life, I still have my last name buried ....)