From Newsgroup: comp.lang.c
Tim Rentsch <
tr.17687@z991.linuxsc.com> writes:
Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
NS <ns@2b.here> writes:
Can all the values of a signed int be represented in an unsigned
int (or signed long in an unsigned long, etc.)?
Obviously not. Negative values cannot be represented in unsigned
types. But I don't think that's what NS meant.
The question is Can all the values of a signed int be represented in
an unsigned int? The question is not can an unsigned int hold all
the values of a signed int. An apple, an orange, and a banana can
represent the integers 1, 2, and 3. All the values of a signed
int can be represented in an unsigned int, as long as UINT_MAX is
greater than INT_MAX.
I already covered this nearly two months ago, in text that you
snipped in your followup.
Some of the values of a signed int are negative. Negative values
cannot be represented in an unsigned int. Or are you saying that the
siged int value -1 can "represent" the unsigned int value UINT_MAX?
That's not what "represent" means.
C currently requires UINT_MAX to be greater than INT_MAX; this is
new in C23 -- something I also mentioned previously.
If you're going to wait months before posting a followup, please
retain more context.
--
Keith Thompson (The_Other_Keith)
Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
--- Synchronet 3.22a-Linux NewsLink 1.2