C + + Primer NOTE 2 Basic built-in types

Source: Internet
Author: User

2-1 Note:

1, C + + only specifies the minimum size of each type of memory, while the number of bytes at least long long >=long>=int>=short;

2, the character type is divided into Char, signed char and unsigned char. The type char actually behaves as the above type, specifically determined by the compiler; VS2013, char = = signed char;

Suggestions:

1, clearly know that the value can not be negative, the use of unsigned type;

2, char only for storing characters, need a small integer, with signed char or unsinged char (clearly indicated);

3, the execution of floating point number with double (double with 2 words (64 bits) to represent precision);

2-2 Note:

1, non-bool->bool,0->false, non-0->true;

2, bool-> non-bool,false->0,true->1;

3. When assigning an unsigned type to a value that exceeds the range it represents, the result is that the initial value represents the remainder of the total number of numeric values for the unsigned type;

unsigned char =-1; (0~255);

Actual for -1%256 = 255; The remainder after modulo! 72235878

4. When we assign a symbol type to a value that exceeds the range it represents, the result is undefined!

Signed char c2 = 256; Assuming that Char occupies 8 bits, the value of C2 is undefined.

C + + Primer NOTE 2 Basic built-in types

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.