Skip to content

Commit a120486

Browse files
mikeblomeColin Robertson
authored andcommitted
update to C integer topic per Windows team (MicrosoftDocs#578)
* update to C integer topics per Windows team * Update c-integer-constants.md Fiddled with formatting.
1 parent 25127d0 commit a120486

File tree

1 file changed

+82
-87
lines changed

1 file changed

+82
-87
lines changed
Lines changed: 82 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "C Integer Constants | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "11/04/2016"
4+
ms.date: "02/01/2018"
55
ms.reviewer: ""
66
ms.suite: ""
77
ms.technology: ["cpp-language"]
@@ -17,89 +17,84 @@ manager: "ghogen"
1717
ms.workload: ["cplusplus"]
1818
---
1919
# C Integer Constants
20-
An "integer constant" is a decimal (base 10), octal (base 8), or hexadecimal (base 16) number that represents an integral value. Use integer constants to represent integer values that cannot be changed.
21-
22-
## Syntax
23-
*integer-constant*:
24-
*decimal-constant integer-suffix* opt
25-
26-
*octal-constant integer-suffix* opt
27-
28-
*hexadecimal-constant integer-suffix* opt
29-
30-
*decimal-constant*:
31-
*nonzero-digit*
32-
33-
*decimal-constant digit*
34-
35-
*octal-constant*:
36-
**0**
37-
38-
*octal-constant octal-digit*
39-
40-
*hexadecimal-constant*:
41-
**0x** *hexadecimal-digit*
42-
43-
**0X** *hexadecimal-digit*
44-
45-
*hexadecimal-constant hexadecimal-digit*
46-
47-
*nonzero-digit*: one of
48-
**1 2 3 4 5 6 7 8 9**
49-
50-
*octal-digit*: one of
51-
**0 1 2 3 4 5 6 7**
52-
53-
*hexadecimal-digit*: one of
54-
**0 1 2 3 4 5 6 7 8 9**
55-
56-
**a b c d e f**
57-
58-
**A B C D E F**
59-
60-
*integer-suffix*:
61-
*unsigned-suffix long-suffix* opt
62-
63-
*long-suffix unsigned-suffix* opt
64-
65-
*unsigned-suffix*: one of
66-
**u U**
67-
68-
*long-suffix*: one of
69-
**l L**
70-
71-
*64-bit integer-suffix*:
72-
**i64**
73-
74-
Integer constants are positive unless they are preceded by a minus sign (**-**). The minus sign is interpreted as the unary arithmetic negation operator. (See [Unary Arithmetic Operators](../c-language/unary-arithmetic-operators.md) for information about this operator.)
75-
76-
If an integer constant begins with **0x** or **0X**, it is hexadecimal. If it begins with the digit **0**, it is octal. Otherwise, it is assumed to be decimal.
77-
78-
The following lines are equivalent:
79-
80-
```
81-
0x1C /* = Hexadecimal representation for decimal 28 */
82-
034 /* = Octal representation for decimal 28 */
83-
```
84-
85-
No white-space characters can separate the digits of an integer constant. These examples show valid decimal, octal, and hexadecimal constants.
86-
87-
```
88-
/* Decimal Constants */
89-
10
90-
132
91-
32179
92-
93-
/* Octal Constants */
94-
012
95-
0204
96-
076663
97-
98-
/* Hexadecimal Constants */
99-
0xa or 0xA
100-
0x84
101-
0x7dB3 or 0X7DB3
102-
```
103-
104-
## See Also
105-
[C Constants](../c-language/c-constants.md)
20+
21+
An "integer constant" is a decimal (base 10), octal (base 8), or hexadecimal (base 16) number that represents an integral value. Use integer constants to represent integer values that cannot be changed.
22+
23+
## Syntax
24+
25+
*integer-constant*:
26+
&nbsp;&nbsp;*decimal-constant* *integer-suffix*<sub>opt</sub>
27+
&nbsp;&nbsp;*octal-constant* *integer-suffix*<sub>opt</sub>
28+
&nbsp;&nbsp;*hexadecimal-constant* *integer-suffix*<sub>opt</sub>
29+
30+
*decimal-constant*:
31+
&nbsp;&nbsp;*nonzero-digit*
32+
&nbsp;&nbsp;*decimal-constant* *digit*
33+
34+
*octal-constant*:
35+
&nbsp;&nbsp;**0**
36+
&nbsp;&nbsp;*octal-constant* *octal-digit*
37+
38+
*hexadecimal-constant*:
39+
&nbsp;&nbsp;**0x** *hexadecimal-digit*
40+
&nbsp;&nbsp;**0X** *hexadecimal-digit*
41+
&nbsp;&nbsp;*hexadecimal-constant* *hexadecimal-digit*
42+
43+
*nonzero-digit*: one of
44+
&nbsp;&nbsp;**1 2 3 4 5 6 7 8 9**
45+
46+
*octal-digit*: one of
47+
&nbsp;&nbsp;**0 1 2 3 4 5 6 7**
48+
49+
*hexadecimal-digit*: one of
50+
&nbsp;&nbsp;**0 1 2 3 4 5 6 7 8 9**
51+
&nbsp;&nbsp;**a b c d e f**
52+
&nbsp;&nbsp;**A B C D E F**
53+
54+
*integer-suffix*:
55+
&nbsp;&nbsp;*unsigned-suffix* *long-suffix*<sub>opt</sub>
56+
&nbsp;&nbsp;*long-suffix* *unsigned-suffix*<sub>opt</sub>
57+
&nbsp;&nbsp;*unsigned-suffix* *64-bit-integer-suffix*<sub>opt</sub>
58+
59+
*unsigned-suffix*: one of
60+
&nbsp;&nbsp;**u U**
61+
62+
*long-suffix*: one of
63+
&nbsp;&nbsp;**l L**
64+
65+
*64-bit-integer-suffix*: one of
66+
&nbsp;&nbsp;**i64 I64**
67+
68+
Integer constants are positive unless they are preceded by a minus sign (**-**). The minus sign is interpreted as the unary arithmetic negation operator. (See [Unary Arithmetic Operators](../c-language/unary-arithmetic-operators.md) for information about this operator.)
69+
70+
If an integer constant begins with **0x** or **0X**, it is hexadecimal. If it begins with the digit **0**, it is octal. Otherwise, it is assumed to be decimal.
71+
72+
The following lines are equivalent:
73+
74+
```C
75+
0x1C /* = Hexadecimal representation for decimal 28 */
76+
034 /* = Octal representation for decimal 28 */
77+
```
78+
79+
No white-space characters can separate the digits of an integer constant. These examples show valid decimal, octal, and hexadecimal constants.
80+
81+
```C
82+
/* Decimal Constants */
83+
10
84+
132
85+
32179
86+
87+
/* Octal Constants */
88+
012
89+
0204
90+
076663
91+
92+
/* Hexadecimal Constants */
93+
0xa or 0xA
94+
0x84
95+
0x7dB3 or 0X7DB3
96+
```
97+
98+
## See also
99+
100+
[C Constants](../c-language/c-constants.md)

0 commit comments

Comments
 (0)