C-language in the system

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

In-process

A way of counting. The focus is on how many times a count is in.

1) C language can be recognized in the system
    1. Binary

Every bit. 0 0 1 0 0 1 1 0 1 0 1 0 0 1 0 1 1 0

In the C language, the way to write a binary number is preceded by a 0b or 0B prefix, binary each bit is 0 or 1, every 2 into 1;

2. Eight binary

Every bit. 0 1 2 3 4 5 6 7 10 11

In the C language, the way to write an octal number is to prefix it with a 0 in front, and every 8 into 1;

%o Outputs data in integer variables in eight-binary form

3. Decimal

Every bit. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14

In C language directly write 1 integers, then the default is the decimal, every 10 into 1;

%d outputs data in integer variables in decimal form

4.16 Binary

Every bit. 0 1 2 3 4 5 6 7 8 9 a B c D E F 10 11 12

In C, the way to write a hexadecimal number is preceded by a 0x or 0X prefix, every 16 into 1;

%x outputs data in integer variables in eight-binary form

2). Conversion between the binary a. Basic concepts

Digital: Refers to the number of each digit of this data.

Digits: The position of the numeral in this number. From right to left. Increments from 0.

Cardinality: That is, how many data can be represented by each number of digits.

(cardinality actually refers to the binary of this number).

Bit right: Digital times (cardinality of the number of bits)

Any number of the 0-time parties are 1.

B. Decimal conversion into binary

In addition to the 2 method of taking the remainder. Divide this number by 2. Until the quotient is 1 or 0. Then the last 1 quotient and all remainder are reversed. This is the binary that corresponds to the decimal.

Cases:

The binary of 10 is 1010

The binary of 178 is 10110010

C. binary conversion to decimal

Weighted method: Add this binary number of each digital bit right, is the binary corresponding to the decimal.

10101 each of the 1 digital weights added.

No. 0 Bit right: 1 * 2 of 0 Parties 1

1 * 0

2 * 4

3 * 0

4 * 16

D. Decimal conversion to octal

Except 8 (similar to Decimal to binary method)

E. Eight binary to decimal

Weighted method: The corresponding decimal number is the sum of each 1 digits of octal.

0342

No. 0 Bit: 2 * 8 of 0 Parties 2

1 4 * 8 of 1 32

2 3 * 8 of 2 192

F. binary conversion to octal.

Three-in-one rule: divide this binary from low to high to 1 groups per three. High enough to fill 0 will convert every 1 group to decimal. Finally, the decimal of each 1 group is connected. is the octal corresponding to this binary.

001 011 100) 110 011

1 3 4) 6 3

G. Convert eight binary to binary.

Split three: This octal number of No 1 digital split into 1 three-bit binary number. Connect these binary numbers together.

134674

001 011 100 110 111 100

H. Binary conversion to hexadecimal.

Si He rule: divide this binary from low to high to 1 groups per four bits. High enough to fill 0

Converts each 1 group to the corresponding hexadecimal. Finally, the hexadecimal number of each of the 1 groups converted successfully is linked together.

11100101010111110111101010101

0001 1100 1010 1011 1110 1111 0101 0101

1 c A B E F 5 5

K. 16 binary conversion to binary.

Split the four rules: the hexadecimal Book of every 1 digital split into 1 four-bit binary number, to connect it together.

4dea761;

0100 1101 1110 1010 0111 0110 0001

C-language in the 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.