Inside the computer is a binary digital world, all information access, processing, transmission, are carried out in binary code. Binary has only two numeric symbols, 0,1

Documents:

** has two important concepts for r-base numbers, technical and bit-weight radix: the radix of r-base is R, such as the radix of binary is two bits: the digit power of the radix

I. Binary

Binary means 0,1. Its characteristic is, every two into one, borrow one for two; The bit weight of the integer part is 2, the bit weight of the decimal part is 2, and n and M are the digits of the integer and decimal respectively. In general, a binary number N can be defined as follows

N = an-12 + a2 + …… + a2+a2 +a2 + …… +a2 the value of a is 0, 1,2, or 2, which is the weight, and the value of I is -m to -n

To distinguish numbers in different bases, subscripts are often used to describe them. For example, (1011) is a binary number, (1011) is a decimal number, and (1011) is a hexadecimal number.

  • Binary can also be represented by Ob, for example, Ob1011
  • The hexadecimal value can be Ox, for example, Ox1011

Binary rules of operation: every two into one, borrow one is two. The operation rules of binary addition and multiplication are:

  • Addition operation: 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 10
  • Multiplication operation: 0 × 0 = 0 0 × 1 = 0 1 × 0 = 0 1 × 1 = 1
  • Subtraction: 0-1 = 1

Chestnut: Calculate the values of (1011)2 + (11)2 and (1010)2 – (11)2

1011 + 11 --------------- 1110 1010 1 0-1 1 ------------- 111 11 so the binary calculation is 1011 + 11 = 1110 1010-11 = 111Copy the code

Binary and decimal conversion

As the computer intelligently recognizes binary numbers, it is often necessary to convert binary and decimal numbers in the computer.

2.1 Converting binary to decimal

Conversion rule: the sum is expanded by weight, that is, the coefficient of each piece is multiplied by the corresponding bit weight, and then the sum of each product is decimal.

Chestnut: (1011.101) converted to decimal

(1011.101)  =  1 × 2 + 0 × 2 + 1 × 2 + 1 × 2 + 1 × 2 + 0 × 2 + 1 × 2 =   8        + 0        +  2        + 1        +  0.5      +                0.125                          =   (11.625)

2.2 Converting from decimal to binary

Converting from decimal to binary is done in two steps: integer to decimal

  • Conversion rules for integer parts: divide by 2, reverse order, mod
  • Decimal conversion rules: divide by 2, positive order, take the whole

In the conversion process, divide decimal by 2 to take out the remainder, and then divide the quotient by 2 again and again, taking out the remainder each time until the quotient is 0. Finally, read the remainder in “back to front” order to obtain the binary number

Chestnut: (53) convert to binary

53%2 = 26%2 = 13%2 = 6%2 = 3%2 = 1%2 = 1%2 = 1%2Copy the code

The result (110101).

Decimal decimal conversion to binary, in the conversion process, the first decimal number multiplied by 2, take out the integer, and then multiply the decimal part of the product by 2, take out the integer each time, know that the decimal part of the product is 0; And then press”From front to back“The integer read is the binary number to be obtained

Chestnut: (0.375) convert to binary number

0.375 integer x 2 -- -- -- -- -- -- -- -- -- -- - 0.750 0 x 2 -- -- -- -- -- -- -- -- -- -- - 1.500 1 x 2 -- -- -- -- -- -- -- -- -- -- - 1.000 1Copy the code

The result (0.011)

Since the decimal part of the product of two is continuously multiplied by a decimal decimal, which is not zero, the decimal number of the binary should be determined with specified precision during the actual conversion

Three hexadecimal

Hexadecimal refers to use 16 digital: 0,1,2,3,4,5,6,7,8,9, A, B, C, D, E, F (A – F 0-15) count. Each hexadecimal number in a computer is usually represented by a 4-bit binary number in the common base comparison table

The decimal system (D) Binary (B) Octal (O) Hexadecimal (H)
0 0000 0 0
1 0001 1 1
2 0010 2 2
3 0011 3 3
4 0100 4 4
5 0101 5 5
6 0110 6 6
7 0111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
16 0001, 0000, 1
17 0001, 0001, 11
18 0001, 0010, 12
19 0001, 0011, 13
20 0001, 0100, 14
21 0001, 0101, 15
22 0001, 0110, 16
23 0001, 0111, 17
24 0001, 1000, 18
25 0001, 1001, 19
26 0001, 1010, 1A
27 0001, 1011, 1B
28 0001, 1100, 1C
29 0001, 1101, 1D
30 0001, 1110, 1E
31 0001, 1111, 1F

Conversion between hexadecimal and binary is very convenient by converting each hexadecimal number to the corresponding binary number. Instead, you just take the binary number from the decimal point, and you group it to the left and to the right every four bits, and you fill up the four bits with zeros, and each group corresponds to a hexadecimal number which is the hexadecimal number converted

Chestnut: (10011010110.101) convert to hex

0100   1101  0110. 1010
 |      |     |     |     
 4      D     6.    A
Copy the code

Result: (4d6.a) chestnut: (82B9) converted to binary

 8      2     B     9
 |      |     |     |     
 1000   0010  1010  1001
Copy the code

Results: (1000 0010 1010 1001)

4. Basic knowledge of information

In a computer, any information is stored and processed in the form of data. The data inside the computer is divided into

  • Numerical data
  • Non-numerical data

Numerical data is used to show how much quantity, while non-numerical data represents information such as text, sound, graphics and images

  1. Bit: A bit is the smallest unit of data in a computer system. All data in the calculation is represented in binary, a binary code is called a Bit, **** is the smallest unit of information in the computer
  2. Byte: Eight bits of binary form a byte. The byte is the basic unit of information storage capacity. When storing binary numbers, use theOctet binary code is stored together as a unit. It’s called a byte. Byte.
    • 1B(byte) = 8 bits
    • 1KB = 2B = 1024B
    • 1MB = 2KB = 2B = 1048576B
    • 1GB(gigabytes) = 2MB = 1024MB = 2B
    • 1TB = 2GB = 1024GB = 2B

1KB is read as 1 kilobyte, but the “thousand” does not refer to “1000” in decimal; it is equivalent to “1024” in decimal

  1. Storage unit: A storage unit consisting of several bytes. Each storage unit has a unique number, called “address”, through which you can access the storage unit. The number of bits contained in a storage location (or word) is called word length **. 支那
  2. Word: A word is the content stored in a storage unit. An instruction, a piece of data can be called a word.

4.1 Representation of numerical data information

In practical application, numbers not only have positive and negative, and decimal, the number of positive and negative with “+” “-“, the decimal point with “.” Because the computer can not identify positive and negative signs and decimal points, therefore, must put the positive and negative signs and decimal point digital **. ** Usually, the first bit of a number in a computer is used as a symbol, with the symbol bit 0 representing a positive number and the symbol bit 1 representing a negative number. The numbers represented together with the sign bits are called machine numbers and there are two conventions for the position of the decimal point,

  1. When the position of the decimal point is fixed, the machine number is called “fixed point number “,
  2. The position of the decimal point can be changed, and machine numbers are called floating point numbers.

When the word length is 8 bits, the number of machines can be represented in the following range:

  • The value is an unsigned integer ranging from 0 to 255
  • Signed integer: (01111111) = (127)(11111111) = (-127) that is (-127~127)

When the word length is 16 bits, the number of machines can be expressed as follows:

  • Unsigned integer: (1111 1111 1111 1111) = (65535)0 to 65535
  • Signed integer: (0111 1111 1111 1111) = (32767)(1111 1111 1111 1111) = (-23767) i.e. (-23767~32767)
// JavaScript representation


Copy the code

When the word length is 32,64 bits, the range of machine numbers is the same.

4.2 Representation of non-numerical data information

1. The ASCII

American Standard code for Exchanging information. The most common character encodings in the West. ASCII characters are represented by seven bits of binary and can represent 128 characters

2. Chinese character coding

  • GB code – GB2312-80, China national standard code, including most Chinese characters
  • GBK code – GB code extension, including GB code
  • BIG5 – Standard for encoding traditional Chinese characters used in Taiwan and Hong Kong

Reference documentation

  1. Fundamentals of University Computer — Neusoft Electronics Publishing House (2012)
  2. Principles of Computer Composition (Second Edition) — Neusoft Electronics Publishing House (2014)