What is by default type of integral literal defined below:
0X123 /* hex , int ? unsigned int? long? unsigned long? */
0XFFFFFFFE /* hex , value is (2^32-2)=4294967294 .*/
0123 /*octal */ /* value = 83*/
042747672777 /* octal , greater than 2^32*/ /* value=4691293695 */
I read in some tutorial or book (I don't remeber source) that they are by default of signed int type. Is that correct?
The type of the integral literal is defined less by whether it is a hexadecimal literal, a decimal literal, or an octal literal and more by the value of the literal.
Table 6 — Types of integer constants, in Section 2.14.2 of the C++11 Standard lists the order of types that will be used to capture an integral literal.
The main difference between decimal literals and hexadecimal and octal literals is that the order of types of decimal literals is int
, long
, long long
while the order of types of hexadecimal and octal literals is int
, unsigned int
, long
, unsigned long
, long long
, and unsigned long long
.
User contributions licensed under CC BY-SA 3.0