![]() |
||||||||||||||||||||||||||||||||||||||
» Comments
Other ways
There are other methods for this: a = a * b b = a / b a = a / b Posted by Gerard on September 16, 2006 at 10:45 AM. Re: Other ways There are indeed other ways as well, but they use more processor cycles usually. Xor is efficient simply because it uses a single processor cycle and can't cause any range overflow. Also, the method above is efficient because it uses a single operation, which makes it easier to integrate into specialised microprocessors for example. Another method with similar performaces can be using: a = a + b b = a - b a = a - b But then again, this needs two operations (sum and difference - which can be made with negation and another sum), but it still uses more cycles than a simple xor. Posted by Indy on September 16, 2006 at 12:32 PM. Not Other Ways The two other ways noted above presuppose that variable a has sufficient bits available to store the sum or product of a and b. The original method does not have this restriction. Posted by Mike on October 27, 2006 at 01:39 PM. Add and subtract just have to be invertible no actually capable of preserving the intermediate range title says it all Posted by Anon Ymous on October 31, 2006 at 11:32 PM. Type Actually, it's: a ^= b; b ^= a; a ^= b; Posted by Larry on December 19, 2009 at 07:27 PM. post o post currently, actually no idea Posted by want to say ya on August 25, 2010 at 08:59 AM. |
Random ArticleSearchFeeds![]() All CategoriesArticles
Aetolia - The Midnight Age
How to create the histogram of an image using PHP How to convert an image to grayscale using PHP How to check if an image is grayscale in PHP Interchanging 2 variables without the use of a third Error launching browser window:no XBL binding for browser Convert the AOL user session collection to a MySQL database Introduction to Matlab Creating a customized session handling system in PHP (part II) Creating a customized session handling system in PHP (part I) Firefox crashing with Yahoo! Messenger ADL Search for oDC Video codecs explained Browsershots How to use Auto-Away Message with oDC Create complete Windows XP disk with SP2 and all updates Data Execution Prevention error message in Windows XP Google Mars Logarithmic scale graphs in Excel Urban Dictionary (or wtf does l33t mean?) Learn more about BIOS Backup your Firefox and Thunderbird settings Syndicate your Yahoo 360 profile What is Google PageRank? 'Cannot Open the File: Mk:@MSITStore' Error Message Get your Gmail with Mozilla Thunderbird E-Books links Change the size of your Explorer thumbnails Remove previews from Windows Explorer How can I turn off system beeps? How do I disable Internet Explorer? What are proxies or how do I protect my anonymity? How to set aliases triggers or macros in MushClient What is RSS? Palm Zire 31 fast review oDC Installation and Basic Configuration How I built a 2x80W amplifier (using power modules) Leech/HotLink Protection How to block referrer detection? How to find out your IP address Getting started with Mushclient What is spyware and how do I protect my PC from it? Stumble Upon - random surfing around the web Automatic file backup for Windows users How can I read foreign language sites? Protect your web surfing privacy! What is BitTorrent? No more ads! Adblock for Firefox Why use Firefox instead of Internet Explorer? How do I create my own Yahoo ID? |