I also want to learn C language-Chapter 7: IEEE floating point representation

Source: Internet
Author: User

I have learned how to use unsigned and signed integer representation (with a complement Code). In fact, there are two other types I have not mentioned: string and string, I think these two types are relatively simple. I will understand them at the first glance. The string type is also the same as the string type. It is only a string of C, and there is a 00 at the end. This 00 is used to determine whether the string ends! The variable that references the string actually represents the first address of the string, and then check it in sequence. If 00 is met, the string ends. IEEE floating point representation

IEEE floating point number representation: Symbol bit (1 bit) + exponential position (8 bits) + ending bits (23 bits)

1: The floating point to be expressed is converted into a binary representation. For example:

123456.0f = 11110001001000000

2: move the decimal point to 1 with only one digit. For example:

1.1110001001000000 moved 16 bits in total

3: because every time the decimal point moves to the left, it is equal to the base 2 index plus 1. So:

1.1110001001000000*2 ^ 16

4: In the index part, a total of eight digits are required. When the decimal index is converted to binary, 127 is added first (why is it necessary to add 127 because it puts 127 in front of 0. because the shift is not just to move to one side, the 8-bit center is 7F, and 7F is the decimal 127 ). for example:

16 + 127 = 143 = 10001111

. 0f because it is a positive number, so the symbol bit is 0. (Note: the tail number is 1 less than 1 because the maximum bit is 1, so in order to save memory) So:

Symbol bit (1 digit) + exponential position (8 digits) + ending digit (23 digits)

0 10001111 11100010010000000000000

Then! And then combine them! 01000111111100010010000000000000

Then! Four more places and one group !! 0100 0111 1111 0001 0010 0000 0000

Then! Convert to hexadecimal 4 7 F 1 2 0 0 0

Then! And then combine them! 47F12000

Then! Come back! 0020F147 (why is the VC memory arrangement high to high, low to low)

Then! Check again! :

This way! We can see why the content in the memory is strange when we debug floating point numbers !!!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.