ch2
ch2
Thomas L. Floyd
Ex) 480.52
… 25 24 23 22 21 20.
Binary Weights
Binary-to-Decimal Conversion
Add all weights with 1 (ignoring 0)
Decimal-to-Binary Conversions - I
Iteratively find the maximum weight
Decimal-to-Binary Conversions - II
Iteratively dividing by 2
and get remainders.
Ch.2 Summary
Decimal-to-Binary Conversions - II
For fraction,
Iteratively multiplying by 2
and get carries.
Ch.2 Summary
Binary Addition
The rules for binary addition are
0+0= 0 Sum = 0, carry = 0
0+1= 0 Sum = 1, carry = 0
1+0= 1 Sum = 1, carry = 0
1 + 1 = 10 Sum = 0, carry = 1
Binary Subtraction
The rules for binary subtraction are
0-0=0
1-1=0
1-0=1
10 - 1 = 1 with a borrow of 1
Subtract the binary number 00111 from 10101 and show the
equivalent decimal subtraction.
111
10101
/ / / 21
00111 7
01110 = 14
Ch.2 Summary
Binary Multiplication
The rules for binary multiplication are:
00=0
01=0
10=0
11=1
Ch.2 Summary
Binary Division
The rules for binary division are:
(always the same with decimal operations)
Ch.2 Summary
1’s Complement
1’s complement : reversing (inverting) all the bits.
0 0 1 1 0 1 0 1
Ch.2 Summary
2’s Complement
The 2’s complement : 1’s complement + 1
0 0 1 1 0 1 0 1
0 0 1 1 0 1 1 0
Ch.2 Summary
Examples:
00011110 = +30 00001110 = +14 11111111 = -1
00001111 = +15 11101111 = -17 11111000 = -8
00101101 = +45 11111101 = -3 1 11110111 = -9
Discard carry
Ch.2 Summary
Note that if the number of bits required for the answer is exceeded,
overflow will occur. This occurs only if both numbers have the same
sign. The overflow is indicated by an incorrect sign bit.
BCD
Weights of BCD: 80 40 20 10 8 4 2 1.
ASCII
ASCII is a code for characters.
Originally, ASCII encoded 128 characters and symbols
using 7-bits.
Ex) 35(0100011) -> #, 97(1100001) -> a
The ASCII character for “a” is 1100001 and for “A” is 1000001.
What is the correct bit to append to make both have odd parity?
The ASCII “a” has an odd number of bits that are equal to 1;
therefore the parity bit is 0. The ASCII “A” has an even number
of bits that are equal to 1; therefore the parity bit is 1.
Ch.2 Summary
Example
11010011101100 with 1011