Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Bitwise operation
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Applications== Bitwise operations are necessary particularly in lower-level programming such as device drivers, low-level graphics, communications protocol packet assembly, and decoding. Although machines often have efficient built-in instructions for performing arithmetic and logical operations, all these operations can be performed by combining the bitwise operators and zero-testing in various ways.<ref>{{cite web|url=http://bisqwit.iki.fi/story/howto/bitmath/ |title=Synthesizing arithmetic operations using bit-shifting tricks |publisher=Bisqwit.iki.fi |date=15 February 2014 |access-date=8 March 2014}}</ref> For example, here is a [[pseudocode]] implementation of [[ancient Egyptian multiplication]] showing how to multiply two arbitrary integers <code>a</code> and <code>b</code> (<code>a</code> greater than <code>b</code>) using only bitshifts and addition: <syntaxhighlight lang="c"> c β 0 while b β 0 if (b and 1) β 0 c β c + a left shift a by 1 right shift b by 1 return c </syntaxhighlight> Another example is a pseudocode implementation of addition, showing how to calculate a sum of two integers <code>a</code> and <code>b</code> using bitwise operators and zero-testing: <syntaxhighlight lang="c"> while a β 0 c β b and a b β b xor a left shift c by 1 a β c return b </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)