Why do we need octal and hexadecimal memory address space and hexadecimal? What is the significance of the hexadecimal system?

Source: Internet
Author: User

As we all know, the memory address space is represented by hexadecimal data, such as 0x8049324. Why do we need to represent it in hexadecimal format? What is the significance of the hexadecimal system?

 

In programming, we usually use 10 hexadecimal. After all, C/C ++ is a high-level language.

For example, int A = 100, B = 99;

However, because the representation of data in a computer exists in binary format, sometimes binary can be used to solve the problem more intuitively. However, the binary number is too long. For example, the int type occupies 4 bytes and 32 bits. For example, if the value is 100, the value expressed in the binary number of the int type is:

0000 0000 0000 0000 0110 0100

No one would like to think about or operate on such a long number. Therefore, C and C ++ are not provided inCodeDirectly write binary data. This problem can be solved in hexadecimal or octal. Because the larger the hexadecimal value, the shorter the number expression length.

 

However, why is it 16 or 8 hexadecimal instead of 9 or 20? 2, 8, and 16 are respectively the power 1 of 2, the Power 3, and the Power 4. This allows the three hexadecimal systems to directly convert each other. In octal or hexadecimal mode, the binary number is shortened, but the expression of binary number is maintained.
 

Significance of hexadecimal:
1. An important digital system used in the computer field

2. It is helpful to describe computer theory and design computer hardware circuits. For example, in the logic circuit design, we must consider the completeness of functions, but also the use of as few hardware as possible, the hexadecimal system can play a role in theoretical analysis. For example, a four-bit binary circuit can be a maximum of sixteen States, that is, a hexadecimal form. Only these sixteen States are used or used as many as possible, hardware resources play the greatest role possible.

3. The hexadecimal format is shorter, because during conversion, a hexadecimal number can have four digits at most.

 

Hexadecimal representation:
C, Shell, Python, and other similar languages use the header "0x", for example, "0x5a3 ". The "0" at the beginning makes it easier for the parser to recognize numbers, while "X" represents hexadecimal (for example, "O" represents octal ). "X" in "0x" can be in upper or lower case.

 

Then let's talk about the memory:

A memory address stores a corresponding value, and the memory is equivalent to a large hash table (ADDR, Val). the semantics of the C statement is to change the hash value.

For example, int I = 3;
Assume that the memory address of I is 0x8049320, then the semantics of this sentence is 0x8049320 = 3. After I = 3, I is (0x8049320,3)

Int B = I;
Assume that the memory address of B is 0x8049324, then the semantics of this sentence is 0x8049324 = val = 3 corresponding to I, and B is (0x8049324,3)

Refer:

Hexadecimal
Http://baike.baidu.com/view/230306.htm

Understanding the C pointer: A memory address corresponds to a value
Http://www.cppblog.com/hex108/archive/2011/06/18/124234.html

 

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.