C-Language Advanced day_01

Source: Internet
Author: User

Data type

1.1 Memory

Memory is linear and is addressable in bytes (8b)

1.2 Complement

Complementary features (reciprocal):

0 's complement is 0.

Sign BITS participate in the operation with ordinary bits

The complement can make subtraction into addition.

The range represented by 8-bit data ("128,127") is determined by the Code rules of the complement

Note:-1 (1111 1111)-128 (1000 0000) 127 (0111 1111)

1.3 Data Type Partitioning

Char 0-128 corresponds to the ASCII table

Why do I need data types?

The data type provides the size and access rules for the requested memory unit.

1.4 Type Conversions

1.4.1 Small data to big data

Bottom alignment/ symbol Auto-fill

Positive expansion 0/negative expansion 1

1.4.2 Big data to small data

int a=127;

Char b=a;

a=b=127;

int a=255;

Char b=a;

A=255;B=FFFFFFFF;

No data loss occurred above, only truncated

1.4.3-Implicit conversion

Plastic lifting: at machine, all lower than bits of shaping data-->32 bit shaping data.

Hybrid boost:

Complement + type conversion + symbol fill

Unsigned int fill 0000

The complement operation of Popular science:

The complement of positive numbers: Same as the original code

The complement of the negative number: The sign bit is 1, the remaining bits are the inverse of the original code of the absolute value, then the whole number is added 1.

Subtract from complement:

Subtraction:
Integer: [A] complement = [A] complement + [-b] Complement (mod 2^ (n+1))
Decimal: [A] complement = [A] complement + [-b] Complement (mod 2)

The [-b] complement, or [b] to complement, is to add one to each bit of the sign bit.

1.5 Memory Management

command-line arguments :

int main (int argc ( number of input data ) four bytes, char * argv[] ( input data ) 12 bytes )

1.6 Arrays

array Clear 0: int array "Ten "={0} ;--> The first data is set to 0 , followed by automatic initialization of 0 ;

Of course, arrays and two-dimensional arrays, pointers array There are many problems, I hope you can communicate a lot!!!

study next week, more C Language Improvement day_02 Thank You (* ^_^ *)

C-Language Advanced day_01

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.