In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "what is the representation of the number in the computer". In the daily operation, I believe that many people have doubts about the representation of the number in the computer. The editor consulted all kinds of data and sorted out the simple and easy-to-use operation methods. I hope it will be helpful for you to answer the question of "what is the expression of numbers in the computer?" Next, please follow the editor to study!
(1) binary
The information processed by the electronic computer is only represented by the two simple numbers "0" and "1", or the information encoded with this number. This number system is called binary. To understand the computer, you must first understand the representation of numbers in the computer.
Any number system can be described by the following four rules:
Cardinal rules; carry rules; bit weight rules, operation rules. This distinguishes the numbers represented by different number systems, usually with other subscript letters in right brackets to indicate the number system in parentheses, decimal numbers with D, binary with B, and hexadecimal numbers with H.
Binary system
Described by four rules as follows: binary numbers have only "0" and "1", the base is 2, the largest number is 1, every 2, your weight is a power with 2 as the base. For example, (0101101010) your rights are 27, 26, 25, 24, 23, 22, 21, 20 in turn.
The four arithmetic rules of binary numbers are the same as decimal numbers except for digits and borrowings.
■ binary addition rule
0 0 0 1
0 "1" 1 "1" 10
■ binary subtraction rule
0-0-0-1-1-debit
1-0-1-1-1-0
■ binary multiplication rules
0 × 0 0 1 × 0 0
0 × 1 × 1 × 1
Example 4: binary number 11110 101 to 110
one hundred and ten
101) 11110
-) 101
one hundred and one
-) 101
00
The advantages of binary are:
■ binary has only "0" and "1" numbers, which is easy to express. The high and low voltage, the cut-off and saturation of transistors, and the magnetization direction of magnetic materials can be expressed as "0" and "1" states.
Each bit of the ■ binary number has only two states of 0 and 1, and only two devices are needed to represent it, so the binary number saves the device. Because the state is simple, it has strong anti-interference and high reliability.
The main disadvantage of binary system is that the digits are too long to read and write, and people are not used to it. For this reason, octal and hexadecimal abbreviations are often used. In order to adapt to people's habits, binary numbers are usually used in computers, and decimal numbers are used in input and output, and the conversion between binary and decimal systems is completed by the computer itself.
0 "1" 1 "1" 10
(2) conversion between hexadecimal and number system
There are 16 digits in hexadecimal system, in which Amuri F represents a number of 10-15, the cardinality is 16, and the largest number is 15, which is denoted by F, every 16 digits.
Hexadecimal number is an abbreviation of binary number. There are sixteen combinations of four binary silk numbers, corresponding to 0-15 of the decimal number. The method of converting a binary number to a hexadecimal number is to segment four digits to the left from the decimal point. When the highest and lower places are less than four digits, add 0 to make up the four segments, and then replace them with an equivalent hexadecimal number. Conversely, the way to convert hexadecimal to binary is to write each hexadecimal number in 4-bit binary, and the leftmost or rightmost one can be omitted.
Decimal numbers are converted to binary numbers, usually by cardinal multiplication and division. The integer part and the decimal part are converted respectively, and finally the two parts are combined, that is, the converted binary number.
The integer part is converted by cardinality division, that is, divide by the cardinality 2 of the binary number to take the remainder, and then divide the quotient by 2 to take the remainder, and repeat the process until the quotient is 0. The first remainder is the lowest bit of a binary number, increasing in turn, and the last remainder is the highest bit of a binary number.
The decimal part is converted by cardinality multiplication, that is, multiplying the radix 2 to take the integer, and then multiplying the remaining decimals by 2 to take the integer until the desired precision (the conversion of the decimal part may have infinite loops and infinite non-loops). The first integer is the first place of the binary decimal, decreasing in turn, and the last integer is the lowest place of the binary decimal.
Because the bit weight of any decimal number is expressed as a decimal number, any decimal number can be converted into an equivalent decimal number?
(3) conversion between number systems
How to convert decimal numbers to binary and octal by ●
The rule of converting a decimal number to a binary number: remove the decimal number again and again with 2 until the quotient is 0, and read the remainder from the last remainder in turn, that is, "divide 2 to take the remainder".
For example: convert 41 to binary
1 0 1 0 0 1
0 1 2 5 10 20 41
That is, (41) D = (101001) B
Convert decimal to octal rules: similar to binary, "take the rest except octal".
Example: 41 is converted to octal
More than 51
0 5 41
That is, 41 is converted to octal to 51.
How to convert binary and octal to decimal by ●
Convert binary to decimal: (A1 … An-1an) 2
= (A1 × 2 ^ (nmur1) + … + an × 2 ^ 0) 10
Convert octal to decimal: (A1 … An-1an) 8
= (A1 × 8 ^ (nmur1) + … + an-1 × 8 ^ 1 + an × 8 ^ 0) 10
Example: (10001010) 2 = (1 × 2 ^ 7 + 0 × 2 ^ 6 + 0 × 2 ^ 5 + 0 × 2 ^ 4 + 1 × 2 ^ 3 + 0 × 2 ^ 2 + 1 × 2 ^ 1 + 0 × 2 ^ 0) 10 = (138) 10
(532) 8 = (5 × 8 ^ 2 + 3 × 8 ^ 1 + 2 × 8 ^ 0) 10 = (346) 10
How to convert binary to octal by ●
Binary octal rule: group decimal numbers from low to high, each group of three digits, each group can represent numbers between 0 and 7, write down the numbers represented by each group in turn.
Example: (11001001) 2 = (011,001)
3 1 1
= (311) 8
Octal binary rule: each octal number is represented as a three-digit binary number, and the useless leading 0 is removed from the sequence of 0 and 1.
Example: (5163) = (101) (001) (110) (011) = (101001110011) 2
At this point, the study of "what is the representation of numbers in the computer" is over. I hope to be able to solve your 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.
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.