On Thu 14 Feb 2002 17:06, Kate wrote:
> Anyone know how to turn a signed number into an unsigned one.
Er. *If* you have a type which can hold the unsigned result, then
2^(size) + (signed number)
eg : 4294967296 + (-1407713022) = 2887254274 (not 2392992828; don't
know where you got that from).
But this will only work if you use a type which can hold the unsigned
version (eg : a 64-bit integer). If you try with a 32-bit integer,
you'll get the signed value back again, as it's a question of
interpretation of the bit pattern, not of storage (2887254274 and
-1407713022 are identical bit patterns in a 32-bit variable).
Colm Buckley : Systems Architect at NewWorldIQ
Personal : colm at tuatha.org | +353 87 2469146 | www.colm.buckley.name
Business : colm at newworldiq.com | +353 1 4334334 | www.newworldiq.com
Alive, occupying space, and exerting gravitational force.
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!