Tutorial-in-process conversion

Source: Internet
Author: User

Recently suddenly qixing, looking at some programs, but a bunch of 16 code to see my head disoriented.

No way, the foundation is too thin, start tutorial!

First say 10 binary conversion to 2 binary

For example 42 want to convert to 2, then 421 straight 2 down, except for the quotient of 0

42/2 = 21 more than 0

21/2 = 10 more than 1

10/2 = 5 more than 0

5/2 = 2 more than 1

2/2 = 1 more than 0

1/0 = 0 More than 1

Write from bottom to top 00101010

1 The front those two 0 are complementary. No use.

It's easy to turn into 10,

^ This is the symbol of power = =. Mathematics for a long time did not learn, early forget the light ...

The number of screens is from 0 onwards

8-bit 7-bit 6-bit 5-bit 4-bit 3-bit 2-bit 1-bit

0*2^7 + 0*2^6 + 1*2^5 + 0*2^4 + 1*2^3 + 0*2^2 + 1*2^1 + 0*2^0

0 + 0 + 32 + 0 + 8 + 0 + 2 + 0

The end result equals 42 Oh yes!

------The following 16 binary-----------------------

The 16 binary must be preceded by 0x, but this does not appear in the binary conversion. (originally did not know what 0x is, also silly asked 0x is how much. )

16 binary, starting from a, representing a=10, until f=15.

Q: Why do you use A to represent 10?

Because the number is not enough. 10 doesn't make up two of the grid. Saharan That's what I understand. )

16 ext. 2 The regular table, too occupies the place below.

For example, take the above 42来 said, 42 = 00101010 This is 10 binary to 2 binary

Each of the 4 numbers is taken separately.

0010 = 2

1010 = A

Convert to 16 binary, 2A o ha ~

16 Binary Direct Turn 10 also improved

2 A uses 16 digits to represent 2A = 2 10

Here 10 is regarded as a person.

2-bit 1-bit

2*16^1 + 10*16^0

32 + 10

Result 42. Perfect!

----------------------------------------------------------------------------

16 binary conversion to 2 binary there is the following law, with a hand-punched table. A little bit of 0 to fill.

0 = 0

1 = 1

2 = 10

3 = 11

4 = 100

5 = 101

6 = 110

7 = 111

8 = 1000

9 = 1001

A = 1010

B = 1011

C = 1100

D = 1101

E = 1110

F = 1111

Tutorial-in-process conversion

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.