By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,378 Members | 3,020 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,378 IT Pros & Developers. It's quick & easy.

Unsigned Int Range

P: 1
Hi All,

i have assigned some large positive int value (32 bit length) X to unsigned int variable and due to the range constraints that variable stores the same positive value X in negative representation say Y (where Y<0).

Now my question is If Y = -1018059492 what would be the value of X? And how to do this converision?

Thanks in advance!
Sep 18 '06 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 8,916
Use pointers, you can pointer and unsigned int pointer at an in variable and thus access the data there with no conversion (of course this may not be a valid thing to do for all variable types but it works for and like sized integer type)

int y = -2;
unsigned int *x = (unsigned int *)&y;

printf("%d is equivilent to %u\n", y, *x);

I've leave you to run it over your specific number.
Sep 18 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.