[cfp-interest 3807] Integer Literal - Low priority
Damian McGuckin
damianm at esi.com.au
Sat Mar 7 21:10:35 PST 2026
There is no such thing as a negative integer literal, although there is a
negated integer literal. I joined working on a task recently where this
fact had escaped those working on things. The specification of integer
literals occurs in 6.4.5.2 where it says that "An integer literal begins
with a digit, ....".
While the fact that it does not include a sign is not spelt out explicitly
in the standard, I do note that the matching scenario for floating-point
literals is spelt out explicitly as an explanatory NOTE in 6.4.5.3#13
(under Remommended Practice) which says that "Floating literals do not
include a sign and are arithmetically negated by the unary - operator.
I have note that others in various discussion groups like Stack Overflow
lament not having such a clause in the standard for integral types to
prompt peoples brains.
One could argue that a similar NOTE to what is said for floating-point
literals would aid clarity for the integral literals in 6.4.5.2.
Just a thought- Damian
More information about the cfp-interest
mailing list