2.0 ARITHMETIC FOR COMPUTER
A binary number
operation will be focusing only in addition, subtraction, multiplication and
division. The fundamental explorations on computer binary number operation will
be more enjoyable if we have a basic understanding of the number calculation
between the human and computer. Therefore, by computing basic types of number
operation is superior practice in the following parts.
2.1 Binary addition
Binary Rules
|
Sum
|
Carry
|
0 + 0 = 0
|
0
|
0
|
0 + 1 = 1
|
1
|
0
|
1 + 0 = 1
|
1
|
0
|
1 + 1 = 1
|
0
|
1
|
How to add Binary numbers
Step 1 :
Align the numbers you wish to add as you would if you were adding
decimal numbers.
Step 2 :
Start with the two numbers in the far right column
Step 3 :
Add the numbers following the rules of decimal addition (1+0 = 1, 0+0
= 0) unless both numbers are a 1.
Step 4 :
Add 1+1 as "10" if present. (it is not
"ten" but "one zero"). Write "0" below and carry
a "1" to the next column.
Step 5 :
Start on the next column to the left.
Step
6 :
Repeat the steps
above, but add any carry. Remember that 1+1 =
10 and 1+1+1 = 11. Remember to carry the "1".
TIPS:
<·
Dont forget to carry
<· You can only use the digits 0 and 1. If
you find yourself using 2 or
any other digit, you did something wrong.
2.2 Binary Subtraction
Here are some examples
of binary subtraction. These are computed without regard to the word size,
hence there can be no sense of "overflow" or "underflow".
Work the columns right to left subtracting in each column. If you must subtract
a one from a zero, you need to “borrow” from the left, just as in decimal
subtraction.
2.3 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






No comments:
Post a Comment