471,873 Members | 2,079 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,873 software developers and data experts.

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 7735
9,065 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 YellowAndGreen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.