C + + Learning Note (ii): Basic data types

Source: Internet
Author: User

Signed integer:

Short at least 16 digits;

int at least as long as short-;

Long at least 32 bits, and at least int--like length;

A long long is at least 64 bits long and at least long--like;

unsigned integer:

unsigned short

unsigned int

unsigned (equals unsigned int)

unsigned long

unsigned long long

The interval constants of the basic data are defined in the Climits header file;

A special integer:

Char: Used to store alphabetic symbols (ASCII code), usually 8 bits;

You can force the setting char to be signed: signed Char and unsigned char;

wchar_t: Wide-byte, generally 16-bit, used to denote Chinese;

Boolean type:

BOOL: denotes true or false;

Floating point number:

FLOAT: single-precision floating-point 6 is a valid number

Double: dual-precision floating-point 10-bit valid digits

Long double: extended precision floating-point 10-bit valid digits

Note Points of operation:

The behavior of the division operator (/) depends on the type of the operand. If the two operands are integers, C + + performs integer division. This means that the decimal part of the result is discarded, so that the result after bismuth is a grain count. If there is one (or two) operand of the full floating-point value, the fractional portion is retained and the result is a floating-point number.

Type conversions:

1. The conversion of long type to short type, using the method of direct truncation;

2. Short-to long-type conversions are performed in two different situations. If the short type is an unsigned integer, the high part of the long type is filled with 0, and if the short type is a signed integer, the long type of the high part fills the symbol bit of the type.

Use aliases:

Redefine some types to prevent differences in the number of types of bytes produced due to different platforms and compilers, which facilitates portability.

1typedef unsignedCharBoolean/*The Boolean value type.*/ 2typedef unsignedLong intUInt32;/*Unsigned-bit value*/ 3typedef unsigned ShortUInt16;/*Unsigned-bit value*/ 4typedef unsignedCharUint8;/*Unsigned 8 bit value*/ 5typedef signedLong intInt32;/*signed-bit value*/ 6typedef signed ShortInt16;/*signed-bit value*/ 7typedef signedCharint8;/*signed 8 bit value*/ 

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.