In
mathematics and digital electronics, a binary
number
is a number expressed in the binary
numeral system,
or base-2
numeral system,
which represents numeric values using two different symbols:
typically 0 (zero) and 1 (one). More specifically, the usual base-2
system is a positional notation with a radix of 2. Because of its
straightforward implementation in digital electronic circuitry using
logic gates, the binary system is used internally by almost all
modern computers and computer-based devices such as mobile phones.
Each digit is referred to as a bit.
Binary arithmetic
Addition
The
simplest arithmetic operation in binary is addition. Adding two
single-digit binary numbers is relatively simple, using a form of
carrying:
- 0 + 0 → 0
- 0 + 1 → 1
- 1 + 0 → 1
- 1 + 1 → 0, carry 1 (since 1 + 1 = 2 = 0 + (1 × 21) )
Adding
two "1" digits produces a digit "0", while 1 will
have to be added to the next column. This is similar to what happens
in decimal when certain single-digit numbers are added together; if
the result equals or exceeds the value of the radix (10), the digit
to the left is incremented:
- 5 + 5 → 0, carry 1 (since 5 + 5 = 10 = 0 + (1 × 101) )
- 7 + 9 → 6, carry 1 (since 7 + 9 = 16 = 6 + (1 × 101) )
- Addition table
+
|
0
|
1
|
---|---|---|
0
|
0
|
1
|
1
|
1
|
10
|
Subtraction
Subtraction
works in much the same way:
- 0 − 0 → 0
- 0 − 1 → 1, borrow 1
- 1 − 0 → 1
- 1 − 1 → 0
Subtracting
a "1" digit from a "0" digit produces the digit
"1", while 1 will have to be subtracted from the next
column. This is known as borrowing.
The principle is the same as for carrying. When the result of a
subtraction is less than 0, the least possible value of a digit, the
procedure is to "borrow" the deficit divided by the radix
(that is, 10/10) from the left, subtracting it from the next
positional value.
* * * * (starred columns are borrowed from) 1 1 0 1 1 1 0 − 1 0 1 1 1 ---------------- = 1 0 1 0 1 1 1
Multiplication
Multiplication
in binary is similar to its decimal counterpart. Two numbers A
and B
can be multiplied by partial products: for each digit in B,
the product of that digit in A
is calculated and written on a new line, shifted leftward so that its
rightmost digit lines up with the digit in B
that was used. The sum of all these partial products gives the final
result.
Since
there are only two digits in binary, there are only two possible
outcomes of each partial multiplication:
- If the digit in B is 0, the partial product is also 0
- If the digit in B is 1, the partial product is equal to A
For
example, the binary numbers 1011 and 1010 are multiplied as follows:
1
0 1 1 (A)
× 1 0 1 0 (B)
---------
0 0 0 0 ← Corresponds to the rightmost 'zero' in B
+ 1 0 1 1 ← Corresponds to the next 'one' in B
+ 0 0 0 0
+ 1 0 1 1
---------------
= 1 1 0 1 1 1 0
× 1 0 1 0 (B)
---------
0 0 0 0 ← Corresponds to the rightmost 'zero' in B
+ 1 0 1 1 ← Corresponds to the next 'one' in B
+ 0 0 0 0
+ 1 0 1 1
---------------
= 1 1 0 1 1 1 0
Multiplication table
*
|
0
|
1
|
---|---|---|
0
|
0
|
0
|
1
|
0
|
1
|
0 comments:
Post a Comment