C 정수 상수
"정수 상수"는 정수 계열 값을 나타내는 10진수(기수 10), 8진수(기수 8) 또는 16진수(기수 16)입니다. 정수 상수는 변경할 수 없는 정수 값을 나타낼 때 사용합니다.
구문
integer-constant:
decimal-constant integer-suffix optoctal-constant integer-suffix opt
hexadecimal-constant integer-suffix opt
decimal-constant:
nonzero-digitdecimal-constant digit
octal-constant:
0octal-constant octal-digit
hexadecimal-constant:
0x hexadecimal-digit0X hexadecimal-digit
hexadecimal-constant hexadecimal-digit
nonzero-digit: 다음 중 하나
1 2 3 4 5 6 7 8 9octal-digit: 다음 중 하나
0 1 2 3 4 5 6 7hexadecimal-digit: 다음 중 하나
0 1 2 3 4 5 6 7 8 9a b c d e f
A B C D E F
integer-suffix:
unsigned-suffix long-suffix optlong-suffix unsigned-suffix opt
unsigned-suffix: 다음 중 하나
u Ulong-suffix: 다음 중 하나
l L64-bit integer-suffix:
i64
정수 상수는 빼기 기호(–)가 앞에 없는 경우 양수입니다. 빼기 기호는 단항 산술 부정 연산자로 해석됩니다. 이 연산자에 대한 자세한 내용은 단항 산술 연산자를 참조하십시오.
정수 상수가 0x 또는 0X로 시작되는 경우 16진수이고, 숫자 0으로 시작되는 경우에는 8진수입니다. 두 경우에 해당하지 않으면 10진수로 간주됩니다.
다음 코드 줄은 동일합니다.
0x1C /* = Hexadecimal representation for decimal 28 */
034 /* = Octal representation for decimal 28 */
공백 문자는 정수 상수의 숫자를 구분할 수 없습니다. 다음 예제에서는 올바른 10진수, 8진수 및 16진수 상수를 보여 줍니다.
/* Decimal Constants */
10
132
32179
/* Octal Constants */
012
0204
076663
/* Hexadecimal Constants */
0xa or 0xA
0x84
0x7dB3 or 0X7DB3