In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail the sample analysis of data types in C language. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
(1) introduction of data types
We have learned about the basic built-in types and the amount of storage space they take up. :
The meaning of the type:
Use this type to open up the size of memory space (size determines the scope of use).
The perspective of how to look at memory space.
1.1 basic classification of types
Plastic family:
Floating point family:
Construction type:
Pointer type
Null type:
(II) the storage of plastic surgery in memory
We said earlier that the creation of a variable is to open up space in memory.
The size of space is determined according to different types.
So let's talk about how the data is stored in the open memory.
For example:
We know that four bytes of space is allocated to a. Then how to store it?
2.1 original code, inverse code, complement code
Signed numbers (integers) in a computer can be expressed in three ways, namely, original code, inverse code and complement code.
The three representation methods all have two parts: symbolic bit and numerical bit, with 0 for "positive" and 1 for "negative", but the three methods of numerical bit are different.
2.2 in-depth analysis
The original, inverse and complement of positive numbers are all the same.
For plastic surgery: the data is actually stored in memory is a complement.
Why?
Analyze 1 with an example:
Analyze 2 with examples
By understanding the underlying concept of the computer, our brain can easily know that the first bit of the machine number is the symbol bit, but it is very difficult and complicated for the computer basic circuit design to distinguish the first bit is the symbol bit. in order to make the underlying design of the computer more simple, people began to explore the use of symbol bits to participate in the operation, and using the method of keeping only addition, we know that minus a number. It is equal to adding the negative number of this number, that is, 1-1 = 1 + (- 1) = 0, which makes the computer operation easier and allows symbol bits to participate in the operation.
Because the complement can store an extra-128, and what is stored in the underlying layer of the computer is the complement, the storage range of an 8-bit binary number in the computer is represented by the complement [- 128127] rather than the original code or inverse code [- 127127]. This also explains why the value range of a byte in the computer is [- 128127].
This can also answer the question we started to ask. The use of original code, inverse code and complement code is a data storage representation designed by people in order to make the symbol bits participate in the operation and make the underlying operation of the computer easier.
This is the end of this article on "sample Analysis of data types in C language". I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.