O
Old Wolf
I've solved it:
int i= INT_MIN;
unsigned int u= 0U-(unsigned)i;
This has taken too long for something so trivial.
I posted this solution 18 hours ago..
(note that the "0U" makes no difference)
I've solved it:
int i= INT_MIN;
unsigned int u= 0U-(unsigned)i;
This has taken too long for something so trivial.
I posted this solution 18 hours ago..
(note that the "0U" makes no difference)
Robbie Hatley said:Life's not fair. There are never any guarantees of anything,
even if some standard says there are. Live with it.
Example: In C, the latest standard mandates that all compilers
provide data type "long long int". BUT, some compilers don't.
Oh well.
Example: In C++, the latest standard mandates that all compilers
impliment keyword "export" (for exporting templates). But many
(most?) C++ compilers don't. Oh well.
But I think most C and C++ compilers DO have type "long long int",
and I believe that in *ALL* which do, this type has much greater
bit width than type "int".
If you think this is not so, then tell me of a compiler where:
char = 1 bytes
short = 2 bytes
int = 4 bytes
long = 4 bytes
long long = 4 bytes
I doubt anyone is going to bother implimenting "long long" only
to make it the same as "int".
I tell you what... I'll mail $2 in cash to the first person
who can demonstrate to me a popular C compiler which impliments
"int", "long", and "long long" as all being the same bit width.
I think you can call that a "money back guarantee".
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.