Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the data expression inside the computer

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to understand the data expression inside the computer". In the daily operation, I believe that many people have doubts about how to understand the data expression inside the computer. The editor consulted all kinds of materials and sorted out the simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to understand the data expression inside the computer". Next, please follow the editor to study!

1.3 data representation within the computer

The general principle of data expression in the computer is to digitize and digitize all the contents. This is also the basic way to deal with data when programming, and the deeper you understand programming, the more you will agree with this principle.

In fact, the computer can only be like this, because the computer can only store two numbers 0 and 1, so instructions, data, pictures, text and other contents must be digitized into 0 and 1 for storage, transmission and display.

1.3.1 expression of integers

Integers can be divided into positive and negative, but only 0 and 1 can be stored inside the computer, then the symbol is digitized inside the computer, using the highest bit of the binary code to represent the symbol bit, which is specified as 0 for positive and 1 for negative. This is the rule of symbol digitization.

As mentioned earlier, integers are stored in binary form inside the computer. However, in order to facilitate calculation and simplify the structure of CPU, the form of complement is used in storage and operation.

The directly calculated binary forms described above are called the source code of integers. It is stipulated that the source code, inverse code and complement of positive numbers are themselves.

For negative numbers, take a closer look at their composition. Take an 8-bit machine as an example, that is, a number accounts for 8 bits in the computer, that is, a byte, using the highest bit to store symbol bits, and other bits to store values. For example, the original code of-8 is 10001000, the highest bit 1 represents a negative number, and the subsequent 7 bits represent a numerical value.

The inverse code of a negative number means that the symbol bit is unchanged, and the other bits are inverted, that is, 0 to 1, 1 to 0, then the inverse code of-8 is 11110111. The complement of a negative number refers to adding 1 to the numerical bits of the inverse code, and the result obtained after the operation is that only the numerical bits are calculated and the symbol bits are not changed. Then the complement of-8 is 11111000, and in this operation, the low bit is carried out to the high bit.

Rule: the complement of a complement is equal to the original code of a negative number.

That is, if you complement the complement of a negative number, you will get the original code of the negative number.

Being familiar with the expression of integers is very helpful for subsequent understanding of the intervals of data and the values obtained after forced conversion, and is also the basis for bit operations.

Note: decimals, called floating-point numbers in programming languages, are stored in different forms than integers.

1.3.2 expression of characters

Characters refer to individual symbols in the computer, such as punctuation, English letters, Chinese characters and so on. Because these characters are different, the computer can not express them directly, so we use the method commonly used in computer programming to number each character, such as stipulating that the a character number is 97, the b character number is 98, and so on

Because there are many characters that need to be numbered, there are a series of corresponding rules for characters and numbering, so these corresponding tables are called character sets, and the common character sets are ASCII, GB2312, BIG5 and so on.

In the internal storage, operation and transmission of the computer, you only need to use this number.

The character set perfectly solves the problem of character storage and transmission.

So characters in the program can participate in the operation, in fact, participate in the operation is the number of this character, the character set law is the basis of many character transformation logic implementation.

Note: the display of characters is realized by special character display codes.

1.3.3 Summary

In fact, everything inside the computer is stored in digital form. I just hope that through these two simple structures, we can understand the idea of digitizing data, which is one of the common ideas in programming.

Those things about Java programming-- the basis of network programming

Java, JDK, Java Compiler, Javac, Java Foundation

For beginners, or programmers who have not come into contact with network programming, they will feel that the knowledge involved in network programming is very profound and difficult, in fact, this is a misunderstanding, when you are familiar with the syntax, in fact, the basic network programming has now been realized extremely simple.

1.4.1 what is network programming?

The essence of network programming is the data exchange between two devices, of course, in the computer network, the device mainly refers to the computer. Data transmission itself is not very difficult, it is not to send the data from one device to two other devices, and then receive the data feedback from another device.

Today's network programming is basically based on request / response, that is, one device sends request data to another, and then receives feedback from another device.

In network programming, the program that initiates the connection, that is, the program that sends the first request, is called the Client, and the program waiting for other programs to connect is called the Server. The client program can be started when needed, while the server needs to be started all the time in order to connect at all times. For example, take a phone call as an example, the person who dials first is similar to the client, and the person who answers the phone must keep the phone open similar to the server.

Once the connection is established, the client and server can transfer data, and the identities of the two are equivalent.

In some programs, the program has both client-side and server-side functions, and the most common software is software such as BT and emule.

Let's talk about how to establish a connection and how to send data.

1.4.2 IP address and domain name

In real life, if you want to make a phone call, you need to know the phone number of the corresponding person, and if you want to send a letter, you need to know the address of the recipient. The same is true in the network, you need to know the location of a device, you need to use the IP address of the device, the specific connection process is implemented by hardware, programmers do not need to pay too much attention.

The IP address is a stipulation that now uses IPv4, which consists of four digits between 0,255and only 4 bytes are needed for internal storage on the computer. In a computer, IP addresses are assigned to network cards, and each network card has a unique IP address. If a computer has multiple network cards, the computer has multiple different IP addresses. Within the same network, the IP address cannot be the same. The concept of IP address is similar to the concept of phone number and ID card.

Because the IP address is not easy to remember, there is a special concept of domain name (Domain Name), which is to give IP an one-character name, such as 163.com, sina.com and so on. There is a corresponding relationship between IP and domain name. If the IP address is compared to an ID number, then the domain name is your name.

In fact, only IP addresses can be used for data transmission in the network, so before transmission, the domain name needs to be converted to IP, which is specially done by a server called DNS.

So in network programming, you can use IP or domain name to identify a device on the network.

1.4.3 the concept of port

In order to run multiple programs on a single device, the concept of Port is artificially designed. A similar example is the extension number within the company.

It is specified that a device has 216ports, or 65536 ports, and each port corresponds to a unique program. Each network program, whether client or server, corresponds to one or more specific port numbers. Because 0-1024 is mostly occupied by the operating system, the port number after 1024 is generally used in actual programming.

Using the port number, you can find the only program on a device.

So if you need to establish a connection with a computer, you only need to know the IP address or domain name, but if you want to exchange data with a program on that computer, you must also know the port number that the program uses.

1.4.4 data transmission mode

Now that you know how to establish a connection, here's how to transfer data. Let's take a look at how the data is transferred.

On the network, whether wired or wireless, there are two ways of data transmission:

L TCP (Transfer Control Protocol)

Transmission control protocol mode, which is a stable and reliable transmission mode, similar to the phone call in the display. You only need to establish a connection once to transfer data multiple times. Just as the phone only needs to dial the number once to make a continuous call, if what you say is not clear, the other person will ask you to repeat it to ensure that the data transmitted is reliable.

The advantage of using this method is stable and reliable, but the disadvantage is that the cost of establishing and maintaining the connection is high and the transmission speed is not fast.

L UDP (User Datagram Protocol)

User Datagram protocol, which does not establish a stable connection, similar to sending short messages. The data is sent directly each time it is sent. If you send multiple text messages, you need to enter the other party's number multiple times. The transmission mode is unreliable, the data may not be received, and the system only ensures that it will be sent as best as possible.

The advantages of using this method are low overhead, fast transmission speed, and the disadvantage is that data may be lost.

In the actual network programming, we can choose any transmission mode according to our needs, or use a combination of these two methods to achieve data transmission.

1.4.5 the concept of protocol

Protocol (Protocol) is a very important concept in network programming, which refers to the format of data transmission. Because we need to transmit all kinds of information in the network, what we get in the program is a group of values, how to read these values, we need to define the format of this group of data in advance, generate and send data in the client according to the format, the server reads the data in accordance with the format, and then generates the data back to the client in a certain format, and the client reads the data in accordance with the format. A similar example in reality is Telegraph coding, where each number is expressed in specific data.

The protocols of general programs are divided into the data format sent by the client and the data format feedback from the server. Both the client and the server follow this format to generate or process data to achieve complex data exchange between the two.

At this point, the study of "how to understand the internal data expression of the computer" is over. I hope to be able to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report