I. What is a positional numeral system?
A number system, also known as a counting system , refers to a method of representing numerical values using a fixed set of symbols and uniform rules. A method of counting according to the principle of carry-over is called a positional numeral system. For example, in the decimal numeral system , counting follows the principle of "carrying over one when reaching ten."
Commonly used positional number systems:
1. Decimal notation has 10 base numbers: 0 to 9, and carries over when reaching ten;
2. Binary notation has two bases: 0 to 1, and carries over when it reaches two.
3. Octal notation has 8 bases: 0 to 7, and carries over when it reaches eight.
4. Hexadecimal notation has 16 base numbers: 0~9, A, B, C, D, E, F (A=10 , B=11 , C=12 , D=13 , E=14 , F=15). It carries over when it reaches sixteen.
II. The base and place value of positional numeral systems
"Radix" and "place value" are the two elements of a positional numeral system.
1. Cardinality:
The radix is the number of possible digits for each digit in a positional numeral system. For example, a decimal number has ten digits: "0", "1", "3" , ..., "9", so the radix is 10.
2. Authority:
Place value refers to the weight of each digit in a numerical value. For example, in the decimal number 4567, the place values from least significant digit to most significant digit are 100, 101, 102, and 103, respectively. Because:
4567=4x103+5x102+6x101+7x100
3. Place value representation of numbers:
Numbers in any number system can be represented as the sum of polynomials expanded according to their place values.
For example, the decimal number 435.05 can be represented as:
435.05=4x102+3x101+5x100+0x10-1+5x10-2
The characteristic of the place value representation is that each term = a number in a certain place multiplied by a power of the cardinality; and the magnitude of the power is determined by the position of the number.
III. Binary Numbers
Why do computers use binary? Because binary operations are simple, circuits are simple and reliable, and logic is strong.
1. Definition:
Counting is done according to the principle of "carrying over when reaching two", which is called binary number, that is, when each bit reaches 2, it carries over to the next higher bit.
2. Features:
Each number can only contain two digits, 0 and 1; the largest digit in a binary number is 1, and the smallest digit is 0; the base is 2.
For example, 10011010 and 00101011 are two binary numbers.
3. Bit weight representation of binary numbers:
(1101 . 101)2=1x23+1x22+0x21+1x20+1x2-1+0x2-2+1x2-3
4. Rules of operation for binary numbers:
addition operation
①0 + 0 = 0 ③1 + 1 = 10
②0 + 1 = 1 + 0 = 1
Multiplication operations
①0×0=0 ③1×1=1
②0×1=1×0=0
IV. Octal Numbers
1. Definition:
The octal system is a system of counting by carrying over from the nearest eight, where each digit carries over to the next higher digit when the total reaches eight.
2. Features:
Each number can only contain eight digits: 0, 1, 2, 3, 4, 5, 6, and 7; the largest digit in an octal number is 7, and the smallest digit is 0; the base is 8.
For example, (1347)8 and (62435)8 are two octal numbers.
3. Place value representation in octal numbers:
(107.13)8=1x82+0x81+7x80+1x8-1+3x8-2
V. Hexadecimal Numbers
1. Definition:
The number is counted according to the principle of "carrying over one when it reaches sixteen", which is called a hexadecimal number. That is, when each digit reaches 16, it carries over one to the next higher digit.
2. Features:
Each number can only contain one of the sixteen digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F. The largest digit in a hexadecimal number is F, which is 15, and the smallest digit is 0. The base is 16.
For example, (109)16 and (2FDE)16 are two hexadecimal numbers.
3. Place value representation in hexadecimal numbers:
(109.13)16=1x162+0x161+9x160+1x16-1+3x16-2
(2FDE)16=2x163+15x162+13x161+14x160
VI. Correspondence between commonly used number systems
Binary, octal, hexadecimal, and decimal are four commonly used number systems in modern digital systems. The correspondence between these number systems is shown in Table 1.
Table 1. Commonly Used Number Systems
VII. Conversion between number systems
1. Converting a decimal number to a non-decimal number
(1) Converting a decimal integer to a non-decimal integer
①Why do we need to convert between number systems?
The process of converting numbers from one number system to another is called number system conversion.
Because decimal numbers are commonly used in daily life, while computers use binary numbers, it's essential to convert input decimal numbers into binary numbers that the computer can accept. After the computer finishes processing, it then converts the binary numbers back into decimal numbers for output. Both conversion processes are entirely automated by the computer.
② Conversion method
The "remainder method" is used to convert a decimal integer to a non-decimal integer, which means dividing by the base and taking the remainder.
Divide the decimal integer successively by any base of the decimal system until the quotient is 0. Then arrange the remainders from bottom to top.
③ Methods for converting decimal fractions to non-decimal fractions
Converting a decimal fraction to a non-decimal fraction uses the "carry method," which involves multiplying by the base and taking the integer part.
Repeatedly multiply the decimal fraction by the base of other number systems until the current value of the fraction equals 0 or meets the required precision. The integer part of the final product, arranged from top to bottom, is the desired result.
2. Convert non-decimal numbers to decimal numbers
The conversion of non-decimal numbers to decimal numbers uses the "place value method," which involves expanding each non-decimal number according to its place value and then summing them.
3. Conversion between binary, octal, and decimal numbers
(1) Conversion methods between binary and octal numbers
① When converting a binary number to an octal number, use the method of "combining three bits into one".
Using the decimal point as the boundary, group the integer part into three groups of three from right to left, padding with 0s if the most significant bit is less than three. Group the fractional part into three groups of three from left to right, padding with 0s if the least significant bit is less than three. Then, expand each group of three binary digits according to their weights and add them together to obtain a single octal digit.
② When converting an octal number to a binary number, the method of "split one bit into three bits" is used.
That is, to represent each digit of an octal number with the corresponding three binary digits.
③ Conversion methods between binary and hexadecimal numbers
a. When converting a binary number to a hexadecimal number, use the method of "combining four bits into one".
Using the decimal point as the boundary, group the integer part into groups of four from right to left, padding with zeros if the highest bit is less than four. For the fractional part, group the fractional part into groups of four from left to right, padding with zeros if the least significant bit is less than four. Then, expand each group of four binary digits according to its weight and add them together to obtain a single hexadecimal digit.
b. When converting a hexadecimal number to a binary number, use the method of "split one bit into four bits".
That is, to represent each digit of a hexadecimal number with the corresponding four binary digits.