C++primer Study Notes (1)-primitive buit-in types and type conversions

Source: Internet
Author: User

1. Notes on unsigned:

1.unsigned int can be abbreviated as unsigned

2. When using char type, char has 3 kinds of situations, Char, signed char, and unsigned char, and when we write char, the compiler will choose from signed Char and unsigned char. Signed char is -127 ~ 127, unsigned char is 0 ~ 255

3. Do not operate on the unsigned int and signed int types, and the int will be converted to the unsigned int type during the operation, resulting in an error in the result of the operation such as int a = 1, unsigned b = 2; A * b! =-2;

2. Notes on literals:

1. There are 3 cases of integer literal (denoted by the decimal 20来):

1. decimal:20

2. octal:02 4

3. hexadecimal:0x14

2. Representation of floating-point numbers:

1. 3.14159

2. 3.14159e0 (denoted by e, e.g. 3e-2 = 0.03, 3e2 = 300)

3. 12. (equivalent to 12.0)

4. . 011

3. About escape sequences (using ' \ ' to denote characters)

1. Common:

: \ \

double quote  : \ "

single quote : \

2. We use the \ + octal number or the \x + 16 binary number representation character;

when, \ followed by more than 3 digits, only the first 3 digits represent the character, and \x has no limit

4. prefix and suffix for literal

1. Character is + prefix, number is + suffix

2. Common character prefixes:

U (Unicode character)

U (Unicode character)

L (Wide character)

U8 (Utf-8 (string literals only))

3. Common integer Suffixes

U or u (unsigned)

L or L (long)

ll or ll (Long long)

4. Common floating-point suffixes

F or f (float)

L or L (long double)

C++primer Study Notes (1)-primitive buit-in types and type conversions

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.