As far as the preprocessor is concerned, 0xFFFFFFFF
is just a hexadecimal constant. Numbers in preprocessor expressions (which are relevant only in #if
and #elif
directives) are taken to be of the widest available integer type; the preprocessor will treat 0xFFFFFFFF
as a signed integer constant with the value 232-1, or 4294967295
(since, as of C99, there is always an integer type of at least 64 bits).
If it appears anywhere other than a #if
or #elif
directive, then the preprocessor is irrelevant. A hexadecimal constant's type is the first of:
int
unsigned int
long int
unsigned long int
long long int
unsigned long long int
For this particular constant, there are several possibilities:
- If
int
is narrower than 32 bits and long
is wider than 32 bits, then the type is long
;
- If
int
is narrower than 32 bits and long
is exactly 32 bits, then the type is unsigned long
;
- If
int
is 32 bits, then the type is unsigned int
;
- If
int
is wider than 32 bits, then the type is int
.
On modern systems, unsigned int
and unsigned long
are the most likely possibilities.
In all cases, the value of 0xFFFFFFFF
is exactly 232-1, or 4294967295
; it never has a negative value.
However, you can easily get a negative value (say, -1
) by converting (either explicitly or implicitly) the value of 0xFFFFFFFF
to a signed type:
int n = 0xFFFFFFFF;
But this is not portable. If int
is wider than 32 bits, the stored value will be 232-1. And even if int
is exactly 32 bits, the result of converting an unsigned value to a signed type is implementation-defined; -1
is a common result, but it's not guaranteed.
As for ~0
, that's an int
expression whose value has all its bits set to 1 -- which is usually -1
, but that's not guaranteed.
What exactly are you trying to do?
4G-1
is supposed to be?