Float F = 1.3f;
How is it stored on 32 computers?
We know that a float occupies 4 bytes, that is, 32 bits. And the Intel processor is small-end. The low position is in high byte, and the high position is in low byte. For discussion convenience, we first find the 32-bit representation of the floating point number corresponding to 1.3, and then change the byte order.
First, convert 1.3 to binary: the integer is the normal method. For decimal places, it is * 2. If it is greater than 1, it is 1, and less than 1 is. 010011001100110011001100110011 ...... It is omitted later.
Second, convert it to the "scientific notation" with 2 as the base: 1.010011001100110011001100110011*2 ^ 0
Where 0 is the index, and that long string is the base number.
With these preparations, we can perform the following operations:
(1) In the 32bit, the first digit is the sign bit 0, indicating a positive number, and 1 indicates a negative number. Here we are 0.
(2) the next 8 digits represent the index: the actual index + 127 is used. Here we use 0 + 127 = 127 = 01111111
(3) If the remaining 23 digits represent the ending number, we can just copy 01001100110011001100110.
The merging is:
001111111010011001100110 01100110
As mentioned above, our computers are generally small-end computers, so the actual storage order is:
011001100110011010100110
00111111
We will use this knowledge in future studies. Record it here.