Binary, decimal, hexadecimal convert each other

Source: Internet
Author: User

1. Binary->10 System

For example:

1101 (2) =1*2^0+0*2^1+1*2^2+1*2^3=1+0+4+8=13

Converted to decimal to the right-to-left with the binary of each number is multiplied by 2 of the corresponding sub-party, but the second to start from 0

2. Binary turn 16 binary:

To convert the binary to 16, simply separate the binary digits from the right-to-left four-bit unit, the front 0 of the points, and the four-digit binary number to represent a 16-binary.

Said more verbose, is 2^4=16, every four bit binary is exactly 1 bits 16 binary

Example: 10112->0001 0112->18 (16)

3.10 Binary->2 Binary

With 10 binary number constantly except 2, take the remainder, the residue inverted write.

Example: 302

302/2 = 151 more than 0

151/2 = 75 more than 1

75/2 = 37 more than 1

37/2 = 18 more than 1

18/2 = 9 more than 0

9/2 = 4 more than 1

4/2 = 2 more than 0

2/2 = 1 more than 0

1/2 = 0 + 1 so the binary is

100101110

4.10 binary to 16: the principle and the same as the 2, the constant addition of 16, the remainder is inverted write.

For example:

23785/16=1486 Yu 9,

1486/16=92 Yu 14,

92/16=5 Yu 12,

5/16=0 Yu 5

In hexadecimal, 10 corresponds to a,11 corresponds to b,15 for F, and then the remainder to 5ce9,

Then decimal 23785 = hexadecimal 5ce9

5.16 binary to 10 binary: Same as 2-in-turn 10-in.

For example: Turn the above 5ce9 into 10 binary:

9*16^0+e*16^1+c*16^2+5*16^3 = 23785

6.16 Binary Turn binary:

The binary system to 16 binary upside down can be, 16 binary each bit corresponding to the binary 4 bits.

Example: AB

A->1010 b->1011

ab->10101011

Binary, decimal, hexadecimal convert each other

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.