468,513 Members | 984 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,513 developers. It's quick & easy.

Unsigned Int Range

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
1 7622
Banfa
9,056 Expert Mod 8TB
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.

Similar topics

96 posts views Thread by John Harrison | last post: by
1 post views Thread by Bob Hairgrove | last post: by
9 posts views Thread by dam_fool_2003 | last post: by
26 posts views Thread by John Harrison | last post: by
105 posts views Thread by Keith Thompson | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.