How to represent the "C + +" integer constant

Source: Internet
Author: User

Integral constants are integral constants. In the C language, the integer constants used are eight hexadecimal and three decimal.

1) Decimal integer constant: decimal integer constant without prefix. Its digital is 0~9.

The following numbers are valid decimal integer constants: 237,-568, 65535, 1627;
In the program is based on the prefix to distinguish the various binary numbers. Therefore, do not mistake the prefix when writing constants, resulting in incorrect results.

2) Octal integer constant: The octal integer constant must begin with 0, which is prefixed with 0 as the octal number. The digital value is 0~7. The octal number is usually an unsigned number.
The following numbers are valid octal numbers: 015 (decimal 13), 0101 (decimal 65), 0177777 (decimal 65535);

3) Hexadecimal integer constant: The prefix of the hexadecimal integer constant is 0X or 0x. Its digital value is 0~9,a~f or a~f.
The following numbers are valid hexadecimal integer constants: 0X2A (Decimal 42), 0XA0 (decimal 160), 0XFFFF (decimal 65535);

4) integer constant suffix: On a 16-bit word machine, the length of the basic integer is also 16 bits, so the range of the represented number is also limited.

The decimal unsigned integer constant has a range of 0~65535 and a signed number of -32768~+32767.
The octal unsigned number represents a range of 0~0177777. The hexadecimal unsigned number represents a range of 0x0~0xffff or 0X0~0XFFFF.
If the number used exceeds the above range, it must be represented by a long integer number. The number of long integers is denoted by the suffix "l" or "L".

How to represent the "C + +" integer constant

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.