Summary of C ++ basic data types and summary of Data Types

Source: Internet
Author: User

Summary of C ++ basic data types and summary of Data Types

I. Integer

1. Integer types include char, short, int, long, and long. The default values of these five types are signed XX;

Rules:Short must be at least 16 bits; int must be at least the same as short; long must be at least 32 bits and at least the same length as int; long must be at least 64 bits and at least the same length as long.

There are no symbol variants in the last four. Unsigned short, unsigned int, unsigned long, unsigned long. Note that unsigned itself is the abbreviation of unsigned int.

 

We can see that on 32-bit and 64-bit computers, the only difference for integer operations is the size of the int and pointer, of which 32-bit computers occupy 2 bytes of the int, the 64-Bit Memory occupies 4 bytes. The pointer size is the same as the int size.

2. wchar_t "char is an 8-character type and can contain up to 256 characters. Many foreign character sets contain more than 256 characters, which cannot be represented by char. The wchar_t data type is generally 16-bit or 32-bit, but different C or C ++ libraries have different rules. For example, GNU Libc specifies that wchar_t is 32-bit. In short, wchar_t represents more than char characters. The wprintf () function in the Standard C ++ and classes and objects in the iostream class library can provide operations related to the wchar_t wide character type ." 3. New types of C ++ 11: char16_t and char32_t char16_t: 16-bit unsigned-> prefix utable: char32_t: 32-bit unsigned-> the prefix utable shows that VS2013 does not support char16_t and char32_t

Ii. Floating Point

There are three floating points. The float, double, and long double rules are as follows: Float should be at least 4 bytes; double should be at least 6 bytes, and not less than float; long double should be at least as much as double.Three types, with an exponential range of at least-37 ~ 37. float32-bit, double64-bit, long double80, 96, or 128-bit. I have measured 64-bit long double on VS2013.

 

3. prefix and suffix.

1. Prefix: starting with 0 indicates octal, and starting with 0x or 0X indicates hexadecimal. 2. Suffix: -- l or L indicates long constant -- u or u indicates unsigned int constant -- ul, uL, Ul, lU, lu, LU, Lu indicates unsigned long constant. (Lu can be expressed in any order and in case.) -- ll and LL indicate long constants. -- Ull, Ull, uLL, and ULL indicate unsigned long constants. 3. For floating-point constants, -- f or F indicates float -- l or L indicates long double -- all others indicate double 4, and the rules without a suffix -- use as small a type as possible: -- For hexadecimal: int-> long -- for hexadecimal or hexadecimal: int-> unsigned int-> long-> unsigned long

 

Refer to: C ++ Primer Plus and Baidu encyclopedia.

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.