Why are there no sign characters in the syntax of constants?

Why does the standard not contain a signed character in the syntax of constants?

Only numbers are mentioned here, and the sign is present only in exhibitors .

+4
source share
2 answers

The standard does not bother the sign before numeric literals, because it will be redundant.

The syntax already captures the sign as part of the unary plus +and unary minus -operators. When you write

int a = -4;

the syntax of the right-hand side could be adequately described as a unary minus expression -with an operand 4. This is an approach that takes the standard.

+7
source

- -2, 4-2 ( ). , -2147483648 - 2147483648 ( int, a long, int - 32 , long ). .

- , -2147483648 , x-1 , . , , C.

+5

Source: https://habr.com/ru/post/1671663/


All Articles