To my understanding, F represents 1111, so how come 0x7FFFFFFF will
represent some value more than 32 bits?
If you are assigning 0x7FFFFFFF to a variable that is more than
32 bits, then leading zeros will be used for the remaining bits.
For example, on a system with a 64 bit int,
int foo = 0x7FFFFFFF;
would initialize foo to 0x000000007FFFFFFF .
This is the merely the same practice as assuming leading zeros
for decimal numbers -- e.g., when you write the number 64,
you do not have to write 00000000064 to indicate 0 hundreds,
0 thousands, 0 ten-thousands and so on. [Note: in C, explicitly
giving leading 0s on a constant has a specific meaning, of indicating
that the constant has been written in octal.]
The poster who replied to you saying that,
int biggest = 0x7FFFFFFF;
would work on a system with 64 bit int was correct: it would
create a 64 bit int whose value is 31 consequative binary 1s.
The poster indicated that whether that is what you *wanted* would
depend on the context, and if what you *wanted* was the maximum
positive int available on the implementation, then you should
write something like,
int biggest = INT_MAX;
where INT_MAX is defined in the standard header file limits.h .
What the poster who replied to you implied, but did not say outright,
is that coding
int biggest = 0x7FFFFFFF;
does *not* mean that the variable named 'biggest' will somehow be
assigned the maximum positive int for the implementation: it just
assigns that particular constant value to a storage location whose
human-readable name is 'biggest', and it might -happen- that that
particular constant is the largest positive int for that
implementation. Compilers don't care what human-readable name is used:
exactly the same thing would happen for
int smallest = 0x7FFFFFFF;