|
|
| Author |
Message |
victorf
Joined: 01 Jan 2006
Posts: 342
Location: Schenectady, New York
|
|
Posted: 25 June 2007, 19:05 PM Post subject: 2s complement |
|
|
Is there a cool way to find the 2s compliment of an UnsignedLong? The directions I have say invert all bits then add 1 to get the 2s compliment. What is the BEST way do do this?
Any enlightenment will be appreciated.
Vic |
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Posts: 2593
Location: Portland, OR
|
|
Posted: 25 June 2007, 20:08 PM Post subject: Re: 2s complement |
|
|
| victorf wrote: | | Is there a cool way to find the 2s compliment of an UnsignedLong? | Most modern computers represent negative numbers using the two's complement system. Consequently, you can usually perform a two's complement operation simply by taking the negative of a value. The ZBasic compiler allows negation of unsigned operands so that would be the most expeditious way to achieve your objective. |
|
| Back to top |
|
 |
|