int? Is it signed or unsigned or is it implementation defined like char?
int? Is it signed or unsigned or is it implementation defined like char?
int is signed unless declared as unsigned.
Thanks for the clarification. You wouldn't mind telling which section of the C Standard Reference Manual says this, would you?
Code:6.2.5 Types 4. There are five standard signed integer types, designated as signed char, short int, int, long int, and long long int.
Thank you, cwr.
I have one more question: a hexedecimal value (0x0f) is int, too, according to the standard - correct?
If that's the case. If I did this: 0x0f. That looks like I'm declaring a 1 byte (e.g char) value to work with, but, since hex's are int. it's actually taken (by the compiler/C) as 0x0000000f - an int.
Am I wrong or right?
If you have a copy of the standard, see 6.4.4.1 (ISO).
In the case of 0x0f, it will be treated as an int, because it's the first type it will fit (char is not counted). If the constant is too big to fit in int, it will try unsigned int, long int, unsigned long int, long long int (C99), unsigned long long int (C99).
Were it decimal, it would first try int, then long int, then long long int (C99).
In other words, on a int is 32 bits, long long is 64 bits system, the constant 4000000000 would be of type long long int, but the same value expressed in hex (0xee6b2800) will have type unsigned int.
An integer constant will never have type char. Even if you expressed it as '\x0f' (a character constant), it is still of type int.
Disclaimer: This is not something I generally pay too much attention to, and I'm summarising from a brief look at the standard. I may have interpreted it incorrectly, but I'm sure I will be corrected if so.
Last edited by cwr; 12-06-2005 at 08:47 PM.