1.3 Data Representation notes and detection questions

Source: Internet
Author: User

1. Summary of binary, octal, decimal, and hexadecimal

Number of possible numbers of base numbers <br/> binary 2 0 1 <br/> octal 8 0 1 1 2 3 4 5 6 7 <br/> decimal 10 0 1 2 3 4 5 6 7 8 9 <br/> hexadecimal notation 16 0 1 2 3 4 5 6 7 8 9 a B C D E F <br/>

2 binary

The binary number is the base of 2. Each binary number is called a single digit, which can be 0 or 1.

The leftmost bit is the highest valid bit (MSB, most significant bit), and the rightmost bit is the lowest valid bit (LSB, least significant bit)

3 integer storage size

The storage unit of all data is byte. Each byte contains 8 characters. Other storage units include words (word, two bytes) and dual words (DWORD, containing four bytes) and the eight-byte section (quadword, which contains 8 bytes ).

The range of unsigned integers:

Power of storage type range (low --> high) 2 <br/> unsigned byte 0 ~ 255 0 ~ (2 ^ 8-1) <br/> unsigned word 0 ~ 65535 0 ~ (2 ^ 16-1) <br/> unsigned double-character 0 ~ 4294 9672 95 0 ~ (2 ^ 32-1) <br/> unsigned four-character 0 ~ (2 ^ 64-1)

4. signed integer

In intel architecture-based computers, it is best to use a valid bit (MSB) to represent the number of symbols: 0 is a positive number, and 1 is a negative number.

Complement representation: A negative integer is generally expressed by a complement. The general algorithm is to add one to the absolute value of a negative integer. Another way is to subtract one from the base number and then subtract each digit in sequence. Then, the final result is added with a complement code corresponding to the number.

For example, in hexadecimal notation 6a3d, because the base number is reduced by 15

6a3d --> (subtract the values of all BITs in 15 Order) 95c2 --> (add one) 95c3

For example, the number of octal nodes is 3456, because the base number is reduced by 7

3456 --> (subtract the value of each digit from 7 in sequence) 4321 --> (add one) 4322

Another example is 11001010 of the binary system. Because the base number minus 1 is 1

1100 0101 --> (1 minus the values of all BITs in turn) 0011 1010 --> (add one) 0011 1011

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Check question ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;

Question 1: What are the terminologies of LSB and MSB?

Answer: The full name of LSB is least significant bit, indicating the percentile bit. The full name of MSB is most significant bit, which indicates the highest valid bit. The highest valid bit is to determine whether the data is positive or negative.

Question 2: What is the decimal number corresponding to the Unsigned binary integer below?
A. 1111 1000b answer: equals to f8h in hexadecimal format, that is, 15*16 + 8 = 248 in decimal format.

B. 1100 1010b answer: equals to the hexadecimal CAH, that is, the decimal 12*16 + 10 = 202

C. 1111 limit B answer: equals to the hexadecimal f0h, that is, the decimal 15*16 + 0 = 240

D. 0011 0101b answer: equal to the hexadecimal 35 h, that is, the decimal 3*16 + 5 = 53

E. 1001 0110b answer: equal to 96 h in hexadecimal format, that is, 9*16 + 6 = 150 in decimal format

F. 1100 1100b answer: equal to the hexadecimal CCH, that is, the decimal 12*16 + 12 = 204

Question 3: What is the sum of binary numbers for each pair below?

A.0000 1111b + 0000 0010b = 0001 0001b

B .1101 0101b + 0110 1011b = 10100 0000b

C.0000 1111b + 0000 1111b = 0001 1110b

D.1010 11B + 1101 1011b = 11000 1010b

E.1001 0111b + 1111 1111b = 11001 0110b

F.0111 0101b + 10101100b = 10010 0001b

Question 4: How many bytes does the following data type contain?

A. Word B. Double (doubleword) C. octal (quadword)

Answer: because one byte contains eight bytes, one word contains two bytes. The double key contains four bytes. Quadword contains 8 bytes.

Question 5: How many data bits are contained in the following data types?

A. Word B. Double (doubleword) C. octal (quadword)

Answer: because one byte contains eight bytes, one word contains two 16 bytes. The dual character contains 4 bytes and 32 characters. The quadword segment contains 8 bytes and 64 bits.

Question 6: How many binary digits are required for the following unsigned integers?

A.65 B. 256 c.32768 d.4095 e.65534 f.20.00007

Answer: 65 is equal to 01000001b, so seven binary digits can be used. 256 is equal to bytes B, so 9 binary digits can be used. 32768 is equal to 1000000000000000b, so 16 binary bits can be used. 4095 equals 1111111111b, so 12 binary digits can be used. 65534 is equal to 111111111110b, so 16 binary bits can be used .. 2134657 equals 1000001001001010000001b. Therefore, 22 Bits can be used for storage.

Question 7: Which of the following hexadecimal decimal numbers correspond?

A to 26 B-452 C-32 D-62

A: The idea of converting a signed decimal number to a hexadecimal number is: 1. Convert the absolute value of a decimal integer to a hexadecimal number. 2. If the decimal integer is negative, the hexadecimal complement code obtained in the previous step is calculated, that is, the complement code obtained after the digits are subtracted from each digit by 15. So we have:

A: the absolute value of 1.-26 is 26, and the hexadecimal value is 001ah. 2. Because-26 is a negative number, you need to calculate the ah complement code. So 001ah --> ffe5h --> ffe6h.

B: the absolute value of 1.-452 is 452, which is converted to hexadecimal 01c4h. 2. Because-452 is a negative number, calculate the 01c4h complement code. So 01c4h --> fe3bh --> fe3ch

C: 1. The absolute value of-32 is 32, which is converted to hexadecimal 0020 H. 2. Because-32 is a negative number, you need to calculate the h complement code. So 0020 h --> ffdfh --> ffe0h

D: 1.-62 the absolute value is 62, which is converted to hexadecimal 003eh. 2. Because-62 is a negative number, we need to calculate the eh complement code. So 003eh --> ffc1h --> ffc2h

Question 8: The following 16-digit hexadecimal number represents a signed integer. convert it to a decimal number.

A.7cab B. c123 c.7f9b d.8230

Answer: The idea of converting a signed hexadecimal number into a decimal number is: 1. If the original hexadecimal integer is a negative number, ask for its complement code. Otherwise, it remains unchanged. 2. Convert the integer obtained in the previous step to the decimal number. If the original hexadecimal number is negative, add a negative number at the beginning of the decimal number.

A: 1.7cabh is a positive number and requires no supplementary code. 2.7cab is converted to a decimal number of 31915

B: 1. The value of c123 H is a negative number and requires a supplementary code. The value is c123h --> 3edch --> 3 eddh. 2.3 edch is converted to decimal number-16093

C: 1.7f9bh is a positive number and requires no supplementary code. 2.7f9b is converted to a decimal number of 32667

D: 1.8230h is a negative number, and the required complement code is 8230 h --> 7dcfh --> 7dd0h. 2.7dcfh to decimal number-32208

Question 9: What is the decimal number of the following signed binary numbers?

A.1011 0101b B .0010 1010b c.1111 116b d.1000 116b e.1100 1100b f.1011 0111b

A: The idea of converting a signed binary number into a corresponding decimal number is: 1. if the maximum bit is 1, it means that the number is represented by a complement code, you must perform a complement to get the corresponding positive number, and then treat it as a non-Signed binary number, convert to a decimal number. 2. If the highest bit is 0, it indicates that the number is a positive number and is directly converted to a decimal number.

A.1011 0101b 1. It is a negative number. Obtain the complement code 1011 0101b --> 0100 1010b --> 0100 1011b 2. Convert 0100 1011b to the decimal number 75.

B .0010 1010b 1. It is a positive number and is directly converted to a decimal number 42.

C.1111 then B 1. It is a negative number. Obtain the complement Code 1111 then B --> 0000 1111b --> 0001 then B 2. Convert 0001 then B to the decimal number 16.

D.1000 limit B 1. It is a negative number. Obtain the complement code 1000 then B --> 0111 1111b --> 1000 then B 2. Convert 1000 then B to the decimal number 128.

E.1100 1100b 1. It is a negative number. Obtain the complement code 1100 1100b --> 0011 0011b --> 0011 0100b 2. Convert 0011 0100b to the decimal number 52.

F.1011 0111b 1. It is a negative number. Obtain the complement code 1011 0111b --> 0100 1000b --> 0100 1001b 2. Convert 0100 1001b to the decimal number 73.

Question 10: What is the 8-bit binary number corresponding to the following signed decimal number?

A.-5 B .-36 C.-16 D.-26

Answer: The idea of converting a signed decimal number to a binary number is to convert the absolute value of the decimal number to a binary number. If the original decimal number is negative, the complement code of the binary number obtained in the first step is calculated.

A.-5 1. Its absolute value is 5 corresponding to the binary number is 0000 0101b 2. Because-5 is negative, so the 0000 0101b complement --> 1111 1010b --> 1111 1011b

B .-36 1. Its absolute value is 36 corresponding to the binary number is 0010 0100b 2. Because-5 is negative, so the 0010 0100b complement --> 1101 1011b --> 1101 1100b

C.-16 1. Its absolute value is 16 corresponding to the binary number is 0001 bytes B 2. Because-16 is negative, so the 0001 bytes B complement --> 1110 1111b --> 1111 bytes B

D.-26 1. Its absolute value is 26 corresponding to the binary number is 0001 1010b 2. Because-26 is a negative number, so the 0001 1010b complement --> 1110 0101b --> 1110 0110b

Question 11: Why Unicode?

A: Because ANSI can only process code smaller than 256 characters, that is, to process international character sets that contain more than 256 characters.

Question 12: What is the maximum value that can be expressed by an unsigned integer of 256?

A: The value range is 0 ~ 2 ^ 256-1. Therefore, the maximum value is 2 ^ 256-1.

Question 13: What is the maximum value that can be expressed by a signed integer of 256?

A: The value range is-2 ^ 255 ~ 2 ^ 255-1. So the maximum value that can be expressed is-2 ^ 255.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.