Forum Index
HomeZBasic Home   Forum RulesForum Rules   Forum FAQForum FAQ   MemberlistMemberlist   UsergroupsUsergroups   RSS FeedRSS Feed
Site SearchSite Search   LinksLinks   DownloadDownload   Digests and SubscriptionsDigests and Subscriptions
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in   RegisterRegister
2s complement

 
Post new topic   Reply to topic    Forum Index -> ZBasic Language
Author Message
victorf



Joined: 01 Jan 2006
Posts: 342
Location: Schenectady, New York

Posted: 25 June 2007, 19:05 PM    Post subject: 2s complement Reply with quote

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 Smile 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 Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    Forum Index -> ZBasic Language Time synchro. with the server - Timezone/DST with your computer
Page 1 of 1

 


All content Copyright © 2005-2012 Elba Corp. All Rights Reserved.
Opinions expressed in posts are those of the author and not necessarily those of Elba Corp.
Powered by phpBB © 2001, 2005 phpBB Group