C + + data type Range

Source: Internet
Author: User

There are many basic data types in C + +, and we need to choose the right data type depending on the range of data that needs to be stored.

The Visual C + + 32-bit and 64-bit compilers recognize the types in the tables later in this article.

  • int (unsignedint)

  • __int8 (unsigned__int8)

  • __int16 (unsigned__int16)

  • __int32 (unsigned__int32)

  • __int64 (unsigned__int64)

  • Short (unsignedshort)

  • Long (unsignedlong)

  • Long Long (unsignedlonglong)

If the name starts with two underscores (__), the data type is non-standard.

The ranges specified in the following table contain both a start value and an end value.

Type name

Bytes Other Name Range of values

Int

4 Signed –2,147,483,648 to 2,147,483,647

unsigned int

4 Unsigned 0 to 4,294,967,295

_int8

1 Char –128 to 127

unsigned _int8

1 unsigned char 0 to 255

__int16

2 short, short int, signed short int –32,768 to 32,767

unsigned __int16

2 unsigned short, unsigned short int 0 to 65,535

__int32

4 Signed, signed int, int –2,147,483,648 to 2,147,483,647

unsigned __int32

4 unsigned, unsigned int 0 to 4,294,967,295

__int64

8 Long long, signed long long –9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

unsigned __int64

8 unsigned long long 0 to 18,446,744,073,709,551,615

bool

1 No False or True

Char

1 No

128 to 127 (default)

0 to 255 (when compiling with/j)

Signed Char

1 No –128 to 127

unsigned char

1 No 0 to 255

Short

2 short int, signed short int –32,768 to 32,767

unsigned short

2 unsigned short int 0 to 65,535

Long

4 Long int, signed long int –2,147,483,648 to 2,147,483,647

unsigned long

4 0 to 4,294,967,295

Long Long

8 None (equivalent to __int64) –9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

unsigned long long

8 None (equivalent to unsigned __int64) 0 to 18,446,744,073,709,551,615

Enum

Varies No A user-defined type that contains a set of named integer constants called enumerators.

Floating

4 No 3.4E +/-38 (7-digit)

Double

8 No 1.7E +/-308 (15-digit)

Long double

Same as Double No Same as Double

wchar_t

2 __wchar_t 0 to 65,535

__wchar_t  , depending on how it is used, specifies a wide character type or multibyte character type.   use   before character or string constants, L   prefix to specify wide character type constants.

signed   and   unsigned   is available for any integral type ( bool   The modifier of the exception).   Note, for mechanisms such as overloads and templates, Char , signed Char   and   unsigned char   is three different types.

The int and unsignedint types have a size of four bytes. However, because the language standard allows portable code to be implementation-specific, the code should not depend on the size of int .

C + + data type Range

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.