First lesson: Converting into a system

Source: Internet
Author: User
Tags binary to decimal decimal to hex

First, the numbering

The computer is binary, because the binary has simple operation, easy to achieve and reliable, for the logical design provides a favorable way to save equipment and other advantages, in order to facilitate the description, but also commonly used 86 or 16 binary as a binary abbreviation. The general technique uses a carry count: It is characterized by:

(1) Every n is one, n is the number of symbols required for each counting system to represent a number of numbers as the base .

Binary: Every two in one, borrow one when two

Octal: Every eight into one, borrow one when eight

Hex: Every 16 in one, borrow one when 16

(2) Number conversion: the principle of conversion between different carry systems: the conversion between different carry counts is based on the principle that if the two rational numbers are equal, the integers of two numbers and fractional parts must be equal respectively. That is, if the first two numbers are equal, the conversion must still be equal

Decimal: There are 10 cardinality: 0,1,2,3,4,5,6,7,8,9 (less than 10)

Binary: There are two cardinality: 0,1 (less than 2)

Octal: There are eight cardinality: 0,1,2,3,4,5,6,7 (less than 8)

Hex: There are 16 cardinality: 0-9,a,b,c,d,e,f (a=10,b=11,c=12,d=13,e=14,f=15)

Ii. conversion between decimal and other binary

(1) Conversion from binary to binary

A. Decimal turn binary (0,1)

The decimal number is divided by 2, and the remainder is written in the opposite direction except to 0 o'clock, which is the binary

For example: 7 of the binary is 111 7 divided by 2 quotient 3 1, 3 continues divided by 2, quotient 1 1 is 7 of the binary number is 111

36 of the binary is 100100 36 divided by 2, the quotient of 18 0,18 continue divided by 2, quotient 9 0,9 divided by 2, quotient 4 1,4 divided by two, quotient 2 0,2 divided by 2, quotient 1 + 1 backwards write 36 binary 100100

B. Binary to Decimal

Calculation formula: a*20+b*21+c*22......n*2n-1=

Binary decimal is converted from the rightmost value to the left, i.e. a represents the rightmost value

Example: 1011001 converted to decimal 89

Calculation formula: 1*20+0*21+0*22+1*23+1*24+0*25+1*26=89

(2) Conversion from octal to binary

A. Decimal to octal (0,1,2,3,4,5,6,7)

Decimal number successive integer divided by 8, until quotient is 0

For example: 49 write eight binary is 61 49 divided by 8, quotient 6 more 1

125 Write eight binary is 175 125 divided by 8, quotient 15 5,15 continue divided by 8, quotient 1 + 7 upside down write 125 octal to 175

B. Eight binary to decimal (with binary to decimal)

Calculation formula: a*80+b*81+c*82......n*8n-1=

For example: 2137 to the right to decimal 1119

Calculation formula: 7*80+3*81+1*82+2*83=1119

(3) Conversion to hexadecimal

A. Decimal to Hex [0-9,a,b,c,d,e,f (A=10,B=11,C=12,D=13,E=14,F=15)]

The decimal number is divided by 16, the quotient is 0, and the remainder is written in the opposite direction, which is the hexadecimal number.

For example: 75 hexadecimal is 4B 75 divided by 16 quotient 4 + 11 11 writing B in turn written in 4 b

296 hexadecimal is 128 296 divided by 16, quotient 18 8,18 continue divided by 16, quotient 1 + 2 in turn writing 128 extremely 296 hexadecimal

b, hexadecimal to decimal (same as binary, octal)

Calculation formula: a*80+b*81+c*82......n*8n-1=

For example: 1BC2 writing hex is 7106

Calculation formula: 2*160+12*161+12*162+1*163=7106

Three or two binary vs. octal, hexadecimal conversions

(1) conversion between binary and octal

A. Binary conversion to octal

For integers, use right-to-left each three-bit group, not enough three-bit left to 0, each set of units converted to be octal

For example: 001 101 111 011

1 5 7 3 that is 1 101 111 011 of the octal number is 1573

B. Conversion of eight decimal numbers to binary system

Replace each octet with a three-bit binary

For example: 3 7 6 2

11 111 110 010 that is 3762 converted to binary number 11 111 110 010

(2) conversion between binary and hexadecimal

A. Binary to hexadecimal (a set of binary digits per four bits, and then to the left for conversion)

For example: 1001 0111 0111 1001

9 7 7 9 that is 1001 0111 0111 1001 Hexadecimal is 9779

B. 16 binary conversion to binary (replaces each digit hexadecimal number with a 4-bit binary number)

For example: 8 7 6 5

1000 0111 0110 0101 that is 8765 converted to binary 1000 0111 0110 0101

First lesson: Converting into a system

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.