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
Subtraction
(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!
==In computing== The [[method of complements]] is a technique used to subtract one number from another using only the addition of positive numbers. This method was commonly used in [[mechanical calculator]]s, and is still used in modern [[computers]]. {| class="wikitable floatright" ! Binary<br>digit ! Ones' <br>complement |-align="center" | 0 | 1 |-align="center" | 1 | 0 |} To subtract a binary number ''y'' (the subtrahend) from another number ''x'' (the minuend), the ones' complement of ''y'' is added to ''x'' and one is added to the sum. The leading digit "1" of the result is then discarded. The method of complements is especially useful in binary (radix 2) since the ones' complement is very easily obtained by inverting each bit (changing "0" to "1" and vice versa). And adding 1 to get the two's complement can be done by simulating a carry into the least significant bit. For example: 01100100 (x, equals decimal 100) - 00010110 (y, equals decimal 22) becomes the sum: 01100100 (x) + 11101001 (ones' complement of y) + 1 (to get the two's complement) ββββββββββ 101001110 Dropping the initial "1" gives the answer: 01001110 (equals decimal 78)
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)