Positional Numbering System
Octal: r=8
123.458=(1*82+2*81+3*80+4*8-1+5*8-2)10
Decimal: r=10
123.4510=(1*102+2*101+3*100+4*10-1+5*10-2)10
Hexadecimal: r=16
123.4516=(1*162+2*161+3*160+4*16-1+5*16-2)10
Represent 1110 in binary, octal, and hexadecimal 1110=10112=138=B16
Represent 1810 in binary, octal, and hexadecimal 1810=100102=228=1216
Represent 123.458 in binary form.
123.458=001 010 011.100 1012
Represent 123.4516 in binary form.
123.4516=0001 0010 0011.0100 01012
MORE Examples:
1. Question: 111.112= 111.114 ?.
2. The PNS system is a representation of numbers based on the radix that is generally agreed upon.
3. The total count of integer and fractional digits for different radix representation is not necessarily the same. The higher the base is, the more compact the representation is.
111.112=1*22+1*21+1*20+1*2-1+1*2-2
=1*4+1*2+1*1+1*0.5+1*0.25
=7.2510
111.114=1*42+1*41+1*40+1*4-1+1*4-2
=1*16+1*4+1*1+1*0.25+1*0.0625
=21.312510
111.115=1*52+1*51+1*50+1*5-1+1*5-2
=1*25+1*5+1*1+1*0.2+1*0.04
=31.2410
222.222=2*22+2*21+2*20+2*2-1+2*2-2
=2*4+2*2+2*1+2*0.5+2*0.25
=14.510
Is this correct?
222.223=2*32+2*31+2*30+2*3-1+2*3-2
=2*9+2*3+2*1+2*0.333...+2*0.111...
=26.888...10
222.224=2*42+2*41+2*40+2*4-1+2*4-2
=2*16+2*4+2*1+2*0.25+2*0.0625
=42.62510
222.225=2*52+2*51+2*50+2*5-1+2*5-2
=2*25+2*5+2*1+2*0.2+2*0.04
=62.4810

|
Converting to Binary Representation:
Represent 62510 in binary

Another method to represent 4110 in binary

Converting to Decimal
Introduction:
1. Converting from any base to the decimal system (base 10) can be accomplished by direct application of the PNS format.
2. This is because the PNS formula can be applied in the target base (in this case, the decimal system).
3. Rewrite the number using the PNS formula in the target base and carry out the computations in the target base.
Binary:
101.112=(1*22+0*21+1*20+1*2-1+1*2-2)10
=(4+0+1+0.5+0.25)10
=5.7510
Octal:
123.458=(1*82+2*81+3*80+4*8-1+5*8-2)10
=(64+16+3+0.5+0.078125)10
=83.57812510
Decimal:
123.4510=(1*102+2*101+3*100+4*10-1+5*10-2)10
=(100+20+3+0.4+0.05)10
=123.4510
Hexadecimal: 123.4516=(1*162+2*161+3*160+4*16-1+5*16-2)10
=(256+32+3+0.25+0.01953125)10
=291.2695312510
Converting Between Binary/Octal/Hexadecimal Bases
Converting with bases to and from bases other than the decimal system,
a direct application of the PNS format can be used.
Rewrite the source number using the PNS formula in the target base and carry out the computations in the target base.
Alternatively:
Convert the number first to decimal from the source base. Convert the decimal number back to the target base.
For numbers that are expressed in the binary, octal or hexadecimal systems, conversions are made simple by
observing the fact that
an octal digit is equivalent to three binary digits and
a hexadecimal digit is equivalent to four binary digits.
Step 1: Convert the
number first to binary from the source base.
Step 2:
Convert the number from binary to the target base.
Example 1.1.4.1: Convert 1234.568 to the hexadecimal system.
Step 1:
Convert the number from source base to binary:
1234.568=001 010 011 100.101 1102
Step 2: Convert the number from binary
to target base:
0010 1001 1100.1011 10002=29C.B816
Example 1.1.4.2: Convert 1234.5616 to the octal system.
Step 1:
Convert the number from source base to binary:
1234.5616=0001 0010 0011 0100.0101 01102
Step 2: Convert the number from binary
to target base:
0
001 001 000 110 100.010 101 1002=11064.2548
Exercise 1.1.4.3: Convert 1111.118 to the hexadecimal system.
Step 1:
Convert the number from source base to binary:
1111.118=001 001 001 001.001 0012
Step 2: Convert the number from binary
to target base:
0010 0100 1001.0010 01002=249.2416
Exercise 1.1.4.4: Convert 1111.1116 to the octal system.
Step 1:
Convert the number from source base to binary:
1111.1116=0001 0001 0001 0001.0001 00012
Step 2: Convert the number from binary
to target base:
0
001 000 100 010 001.000 100 012=10421.0428
Converting from Decimal to Any Radix
Introduction:
1. Converting from the decimal system (base 10) to any other target base can normally be accomplished also by direct application of the PNS format.
2. Rewrite the number using the PNS formula in the target base and carry out the computations in the target base.
3. The problem is carrying out the computations in the target base.
4. The PNS can be applied from a different perspective while keeping the computations in the source base (base 10).
5. For the integer portion, the digits of the converted number in the target base are obtained starting from the least significant bit by successively dividing the number in the source base by the target base.
6. For the fractional portion, the digits of the converted number in the target base are obtained starting from the most significant bit after the fractional point by successively multiplying the number in the source base by the target base.
N=an-1 rn-1 + an-2 rn-2 + ... + a1 r + a0 + a-1 r-1 + a-2 r-2 + ... + a-m r-m
For the integer part
Ninteger=an-1 rn-1
+ an-2 rn-2 + ... + a1 r + a0
N1=N/r = an-1
rn-2 + an-2 rn-3 + ... + a1
Remainder
a0
N2=N1/r= an-1
rn-3 + an-2 rn-+ ... + a2
Remainder
a1
...
Nn-2=N/r= an-1 r + an-2
Remainder
an-3
Nn-1=N/r= an-1
Remainder an-2
For the fractional part:
Nfractional = a-1
r-1 + a-2 r-2 + ... + a-m r-m
N-1=Nf*r=
a-1 + a-2 r-1 + ... + a-m r-m+1
Integer portion
a-1
N-2=(N-1-a-1)*r=
a-2 + ... + a-m r-m+1
Integer portion
a-2
...
N-m=(N-1-a-1)*r=
a-m +...
Integer portion a-m
Example Convert 1234.5610 to base 2.
Remainder
Integer:
2 | 1234
0----------------------------
2 | 617
1-------------------------- |
2 | 308
0------------------------ | |
2 | 15
0---------------------- | | |
2 | 77
1-------------------- |
| | |
2 | 38
0------------------ |
| | | |
2 | 19
1---------------- |
| | | | |
2 | 9
1-------------- |
| | | | | |
2 | 4
0------------ | | | | |
| | |
2 | 2
0---------- | | |
| | | | | |
1
------------- ---- | | | | | | | | | |
| | | | | | | | | | |
1 0 0 1 1 0 1 0 0 1 0
Fraction:
0.56 * 2 = 1.12 Integer
1
0.12 * 2 = 0.2 4
Integer 0
0.24* 2 = 0.48
Integer 0
0.48 * 2 = 0.96
Integer 0
0.96 * 2 = 1.92
Integer
1
... 0.92 * 2 = 1.84 Integer
1
1234.5610 = 10011010010.1000112...
Example Convert 1234.5610 to base 8.
Remainder
Integer:
8 | 123
2-------------
8 | 15
2----------- |
8 | 19
3--------- | |
2---------------------- | | |
| | | |
2 3 2 2
Fraction:
0.56 * 8 = 4.48 Integer
4
0.48 * 8 = 3.8
Integer 3
0.8* 8 = 6.72
Integer
6
0.72 * 8 = 5.76
Integer
5
...
1234.5610=2322.43658...
Convert 1234.5610 to base 16.
Remainder
Integer: 16 |
1234
2-------
16 | 77
D----- | |
4-------------------- | |
| | |
4 D 2
Fraction:
0.56 * 16 = 8.96
Integer
8
0.96 * 16 = 15.36
Integer
F16=1510
0.36 * 16 = 5.76
Integer
5
0.76 * 16 = 12.16
Integer
C16=1210
...
1234.5610=4D2.8F5C16...
ExampleConvert 529.62510 to base 2.
Remainder
Integer: 2
| 529
1---------------------- |
2 | 26
0-------------------- | |
2 | 132
0------------------ | | |
2 | 66
0---------------- | | | |
2 | 33
1-------------- | | |
| |
2 | 16
0------------ | | |
| | |
2 | 8
0---------- | | |
| | | |
2 |
0-------- | |
| | | | | |
2 | 2
0------ | | |
| | | | | |
1------------------- | | | | | | | | |
| | | | | | | | | |
1 0 0 0 0 1 0 0 0 1
Fraction:
0.625 * 2 = 1.25
Integer
1
0.250 * 2 = 0.50
Integer
0
0.500 * 2 = 1.00
Integer
1
529.6252=1000010001.1012...
Example Convert 529.62510 to base 8.
Remainder
Integer: 8
| 529
1-----------
8 | 66
2--------- |
8 | 8
0------- | |
1-------------------- | | |
| | | |
1 0 2 1
Fraction: 0.625 * 8 = 5.0010 Integer 58
529.62510=1021.58
Convert 529.62510 to base 16.
Remainder
Integer:
16 | 529
1---------
16 | 33
1------- |
2------------------- | |
| | |
2 1 1
Fraction: 0.625 * 16 = 10.0010 Integer A16
529.62510=211.A16
Exercise Convert 111.1110 to base 2.
Remainder
Integer: 2 |
111
0----------------------
2 | 55
1-------------------- |
2 | 27
1------------------ | |
2 | 13
1---------------- | | |
2 | 6
1-------------- | | | |
2 | 3
0------------ | | | | |
1------------------------------- | | | | | |
| |
| | | | |
1 0 1 1 1 1 0
Fraction:
0.11 * 2 = 0.22 Integer
0
0.22 * 2 = 0.4
Integer 0
0.4* 2 = 0.88
Integer
0
0.88 * 2 = 1.76
Integer
1
...
111.112=101110.00012...
Exercise Convert 111.1110 to base 3.
Remainder
Integer: 3 |
111
0--------------------
3 | 37
1------------------ |
3 | 12
0---------------- | |
3 |
1-------------- | | |
1--------------------------------- | | | |
|
| | | |
1 1 0 1 0
Fraction:
0.11 * 3 = 0.33 Integer
0
0.33 * 3 = 0.99
Integer
0
0.99 * 3 = 2.97
Integer
2
0.97 * 3 = 2.91
Integer
2
...
111.112=11010.00223...
Exercise Convert 111.1110 to base 5.
Remainder
Integer: 5 |
111
1----------------------
5 | 22
2-------------------- |
4--------------------------------------- | |
| | |
2 1
Fraction:
0.11 * 5 = 0.55 Integer
0
0.55 * 5 = 2.75
Integer
2
0.75 * 5 = 3.75
Integer
3
0.75 * 5 = 3.75
Integer
3
...
111.1110=421.023333335...
Addition of Unsigned Numbers
Introduction:
1. Addition with unsigned fixed-point binary numbers is done in the same way as with numbers in the decimal system.
2. Since a binary digit may take on one of two values, a simple table lookup suffices to determine the carry and sum for adding two binary digits
3. In the addition operation, one adds the addend to the augend resulting in the sum and a 1-bit carry. The size of the sum is one bit more than the size of the larger of the addend or the augend. The extra bit accounts for the possibility of the carry bit.
4. Addition is commutative, hence either number to be added can be the augend and the other the addend.
Addition: Augend+Addend = Carry, Sum
|
|||||||||||||
Example 1.2.1.1: 10012+01012=?
Carry
1
10012
Augend
910
+
01012
+ Addend
+
510
11102
Carry,Sum
1410
10012+01012=11102
Example 1.2.1.2: 11102+01112=?
Carry
11
11102
Augend
1410
+
01112
+ Addend
+
710
101012
Carry,Sum
2110
11102+01112=111012
Example 1.2.1.3: 101010102+010101012=?
Carry
101010102
17010
+
010101012
+
8510
111111112
25510
1010102+010101012=111111112
Example 1.2.1.4: 011111102+001001112=?
Carry
11111
011111102
12610
+
001001112
+
3910
101001012
16510
011111102+001001112=101001012
Example 1.2.1.5: 100011112+110011002=?
Carry
100011
100011112
14310
+
110011002
+
20410
1010110112
34710
100011112+110011002=1,010110112
Subtraction
of Unsigned Numbers
Introduction:
1. Subtraction with unsigned fixed-point binary numbers is done in the same way as with numbers in the decimal system.
2. Since a binary digit may take on one of two values, a simple table lookup suffices to determine the carry and sum for adding two binary digits or the borrow and difference for subtracting two binary digits.
3. In the subtraction operation , one subtracts the subtrahend from the minuend resulting in the difference and a 1-bit borrow. The size of the difference is one more than the size of the larger of he minuend or the subtrahend to account for the possibility of the borrow bit.
4. While the addition operation is commutative, the subtraction operation is not commutative, hence, it is crucial not to confuse the minuend and the subtrahend.
Subtraction: Minuend-Subtrahend = Borrow, Difference
|
|||||||||||||
Example 1.2.2.1: 10012-00102=?
Solution:
Borrow 11
10012
Minuend
910
-
00102
- Subtrahend
-
210
01112
Borrow,Difference
710
10012-00102=01112
Example 1.2.2.2: 00112-01102=?
Solution:
Borrow 1
00112
Minuend
310
-
01102
- Subtrahend
-
610
111012
Borrow,Difference
-310
(-16+13)
00112-01102=111012
(The carry represents a borrow of 16.
The rest of the bits 1101 represent a positive 13.)
Example 1.2.2.3: 100101102-001011002=?
Solution:
Borrow 11
100101102
15010
-
001011002
-
4410
011010102
10610
100101102-001011002=0110110102
Example 1.2.2.4: 001100112-011000102=?
Solution:
Borrow 11
001100112
5110
-
011000102
-
9810
1110100012
-4710
(-256+209)
001100112-011000102=1,110100012
Multiplication of Unsigned Numbers
Introduction:
1. Multiplication with unsigned binary numbers is done in the same way as with numbers in the decimal system.
2. Since a binary digit may take on one of two values, a simple table lookup suffixes to determine the product multiplying two binary digits.
3. In multiplication, one multiplies the multiplicand by the multiplier resulting in the product.
4. The number of bits in the product is the
sum of that for the multiplicand and the multiplier.
Multiplication is commutative, but it is a good practice not to confuse the
multiplicand and the multiplier.
5. When multiplying two binary numbers together, each bit of the multiplier results in a partial sum that must be added together to yield the final product.
6. Each partial sum is either a shifted version of the multiplicand or zero. Multiplication: Multiplicand * Multiplier = Product
|
|||||||||||||
Example 1.2.3.1:
01012 * 01102=?
Solution:
0101
Multiplicand
510
*
0110
* Multiplier
*
610
0000
Partial
Sum
3010
0101
...
0101
0000
Partial Sum
00011110
Product
(Extra bit
in front represents no carry.)
01012 * 01102=000111102
Example 1.2.3.2:
11012 * 11102=?
Solution:
1101
Multiplicand
1310
*
1110
* Multiplier
*
1410
0000
Partial
Sum
18210
1101
...
1101
1101
Partial Sum
10110110
Product
11012 * 11102=101101102
In general, it is not easy to add many operands together in order to arrive at the product. It is much easier to add two operands together in successive steps. The multiplication process can be reformulated in a series of additions. Staring with a partial sum that is initialized to zero,
if the bit in question in the multiplier is a 1,
then the multiplicand is added to the partial sum.
If the multiplier bit is zero, the multiplicand is not added.
With or without addition, the partial sum itself is shifted to the right. This operation is similar to shifting to the next bit to the left in the multiplier.
Example 1.2.3.3:
01012 * 01012=?
Solution:
Partial
Sum
Multiplier
Comments
0000
0101
Initial partial sum set to 0
0101
Add multiplicand
0101
0101
0010 1 010
Shift right partial sum
0000
Do not
add multiplicand
0010
1
0001
01
01
Shift
0101
Add
multiplicand
0110
01
0011 001 0
Shift
0000
Do not
add multiplicand
0011
001
0001 1001 Shift
01012 * 01012=000110012
Example 1.2.3.4:
11012 * 11102=?
Solution:
Partial
Sum
Multiplier
Comments
0000
1110
Initial partial sum set
to 0
0000
Do not
add multiplicand
0000
0000 0 111
Shifted right
1101
Add multiplicand
1101 0
0110 10
11
Shifted
1101
Add multiplicand
10011 10
1001 110 1
Shifted
1101
Add multiplicand
10110 110
1011
0110
Shifted
11012 * 11102=101101102
Example 1.2.3.6:
11112 * 11112=?
Solution:
Partial
Sum
Multiplier
Comments
0000
1111
Initial partial sum set to 0
1111
Add
multiplicand
1111
0111 1 111
Shift
1111
Add
multiplicand
10110 1
1011 01
11
Shift
1111
Add
multiplicand
11010 01
1101 001
1
Shift
1111
Add multiplicand
11100 11
1110 011 Shift
11112 * 11112=11100112
Division of Unsigned INtegers*
Introduction:
1. Division with unsigned fixed-point binary numbers is done in the same way as with long hand division of numbers in the decimal system.
2. In division, one divides the dividend by the divisor resulting in the quotient and the remainder.
3. The number of bits in the quotient is the same as the dividend. In the extreme case that the divisor is 1, the quotient would be the dividend itself. The number of bits in the remainder is the same as the divisor because the remainder cannot be larger than the divisor.
4. Division is not commutative, hence it is crucial not to confuse the dividend from the divisor.
Division: Dividend / Divisor = Quotient + Remainder/Divisor
Example 1.2.4.1:
11001112 / 1102=?
Solution:
10001
Quotient
110 | 1100111
Divisor and dividend
110
Subtract divisor
00
Partial remainder
00
Remainder insufficient for subtraction
01
00
Remainder insufficient for subtraction
11
00
Remainder insufficient for subtraction
111
110
Subtract divisor
001
Remainder
11001112 / 1102=100012+12 / 1102
Example 1.2.4.2:
0111112 / 0112=?
Solution:
1010
Quotient
011
| 011111
Divisor and dividend
011
Subtract divisor
01
Partial remainder
00
Remainder
insufficient for subtraction
011
011
Subtract divisor
01
00
Remainder
insufficient for subtraction
1
Remainder
0111112 = 10102 * 0112+12
Example 1.2.4.3:
11001112 / 0102=?
Solution:
110011
Quotient
010
| 1100111
Divisor and dividend
10
Subtract divisor
10
Partial remainder and
next digit
10
Subtract divisor
00
Partial remainder and
next digit
00
Remainder insufficient
for subtraction
01
Partial remainder and
next digit
00
Remainder
insufficient for subtraction
11
Partial remainder and
next digit
10
Subtract divisor
11
Partial remainder and
next digit
10
Subtract divisor
1
Remainder
11001112 =1100112 * 0102+12
Example 1.2.4.4: 1111112 / 1112=?
Solution:
1001
Quotient
111
| 111111
Divisor and dividend
111
Subtract divisor
01
Partial remainder
00
Remainder insufficient
for subtraction
11
Partial remainder and next
digit
00
Remainder insufficient
for subtraction
111
Partial remainder and next
digit
111
Subtract divisor
0
No remainder
1111112 / 1112=100012
Addition of Signed Numbers*
Introduction
1. The addition of signed fixed-point binary numbers represented in the Radix Complement Representation is similar to the unsigned case.
2. Since the numbers are signed, they are represented in Radix Complement Representation.
3. The Radix Complement Representation is defined with respect to a predefined word length.
4. With a given word length, the range of representing both positive and negative numbers is limited. Hence, there is always a chance of overflow or underflow when adding signed fixed-point binary numbers.
5. Overflow occurs when the resultant sum is larger than the range for the given word length.
6. Underflow occurs when the resultant sum is smaller than the range for the given word length.
7. When adding two signed numbers together,
three possible scenarios may happen:
Case I: Both numbers are positive.
Case II: Both numbers are negative.
Case III: The numbers are of opposite sign.
Case I:
Both numbers are positive.
Ns=N1+N2
Ns is the sum, N1 the augend, and N2 the
addend. In this case, the addition is similar to the unsigned case. However,
since the range is limited, it is possible that the sum is larger than the
allowable range thus causing overflow. Overflow
occurs when the sum is negative.
Example 1.3.2.1: Find Ns=N1+N2
where N1=+92 and N2=+19 expressed in 8 bit 2s Complement
representation.
Solution:
N1=010111002
N2=000100112
Binary
Decimal
Carry
1
01011100
+92
+
00010011
+ +19
01101111
+111
Ns=010111002+000100112=011011112
Example 1.3.2.2: Find Ns=N1+N2
where N1=+92 and N2=+115 expressed in 8 bit 2s Complement
representation.
Solution:
N1=010111002
N2=011100112
Binary
Decimal
Carry
111
01011100
+92
+
01110011
+ +115
11001111
+207
Ns=010111002+011100112=OVERFLOW
In this example, since the resultant sum is larger than the possible range for
numbers with a word length of 8 bits in 2s complement form, the answer must be
OVERFLOW.
Case II: Both numbers are
negative.
(2n-N1)+(2n-N2)=(2n-N1-N2)+2n
=Ns+2n
1. Note that what is being added are representations (2n-N1)and (2n-N2) .
2. The addition of the two representations results in the addition of two 2n.
3. Only one 2n is needed to represent the resultant negative number.
4. The second 2n is represented by the carry and should be deleted from the sum of the addition to get the correct representation of the negative result.
Example 1.3.2.3: Find Ns=N1+N2
where N1=-93 and N2=-29 expressed in 8 bit 2s Complement
representation.
Solution:
N1=101000112
N2=111000112
Binary
Decimal
Carry
11 11
10100011
-93
+
11100011
+ -29
110000110
-122
(The carry
is ignored indicating the subtraction of 2n.)
Ns=101000112+111000112=100001102
Example 1.3.2.4: Find Ns=N1+N2
where N1=-93 and N2=-125 expressed in 8 bit 2s Complement
representation.
Solution:
N1=101000112
N2=100000112
Binary
Decimal
Carry
11
10100011
-93
+
10000011
+ -125
100100110
-218
Ns=101000112+100000112=UNDERFLOW
In this example, since the resultant sum is smaller than the possible range for
numbers with a word length of 8 bits in 2s complement form, the result must be
UNDERFLOW.
Case III: Both numbers are of opposite sign. Without loss of generality, assume N1 is positive and N2 is negative.
1. If |N1||N2|, then the
result is positive. The extra 2n is dropped as represented by the
deletion of the generated carry.
N1 + (2n-N2)=(N1-N2)+2n
2. If |N1||N2|, then the
result is negative. The extra 2n is needed for the complement in the
representation of the result. Consequently, there is no carry generated.
N1 + (2n-N2)=(2n-(N1-N2))
Example 1.3.2.5: Find Ns=N1+N2
where N1=+117 and N2=-92 expressed in 8 bit 2s Complement
representation.
Solution:
N1=011101012
N2=101001002
Binary
Decimal
Carry
11 1
01110101
+117
+
10100100
+ -92
100011001
+25
(The carry
is ignored indicating the subtraction of 2n.)
Ns=011101012+101001002=000110012
Example 1.3.2.6: Find Ns=N1+N2
where N1=+92 and N2=-125 expressed in 8 bit 2s Complement
representation.
Solution:
N1=010111002
N2=100000112
Binary
Decimal
Carry
01011100
+92
+
10000011
+ -125
11011111
-33
Ns=010111002+100000112=110111112
When both numbers are of opposite sign, the sum is always valid. Conditions for overflow and underflow will never occur.
Exercise 1.3.2.1: Find Ns=N1+N2
where N1=+85 and N2=-86 expressed in 8 bit 2s Complement
representation.
Solution:
N1=010101012
N2=101010102
Binary
Decimal
Carry
01010101
+85
+
10101010
+ -86
11111111
-1
010101012+101010102=111111112
Exercise 1.3.2.2: Find Ns=N1+N2
where N1=-43 and N2=-22 expressed in 8 bit 2s Complement
representation.
Solution:
N1=110101012
N2=111010102
Binary
Decimal
Carry
1
11010101
-43
+
11101010
+ -22
110111111
-65
Ns=110101012+111010102=101111112
Exercise 1.3.2.3: Find Ns=N1+N2
where N1=+103 and N2=+1expressed in 8 bit 2s Complement
representation.
Solution:
N1=011001112
N2=000011102
Binary
Decimal
Carry
1 111
01100111
+103
+
00001110
+ +14
01110101
+117
Ns=011001112+010011102=101101012
Exercise 1.3.2.4: Find Ns=N1+N2
where N1=+119 and N2=+102 expressed in 8 bit 2s
Complement representation.
Solution:
N1=011101112
N2=011001102
Binary
Decimal
Carry
1
01110111
+119
+
01100110
+ +102
10011101
+221
011101112+011001102=OVERFLOW
Exercise 1.3.2.5: Find Ns=N1+N2
where N1=-18 and N2=-86 expressed in 8 bit 2s Complement
representation.
Solution:
N1=111011102
N2=101010102
Binary
Decimal
Carry
1
11101110
-18
+
10101010
+ -86
110011000
-104
Ns=010111002+000100112=100110002
Exercise 1.3.2.6: Find Ns=N1+N2
where N1=-82 and N2=-86 expressed in 8 bit 2s Complement
representation.
Solution:
N1=101011102
N2=101010102
Binary
Decimal
Carry
1
10101110
-82
+
10101010
+ -86
101011000
-168
Ns=101011102+101010102=UNDERFLOW2
Subtraction of Signed Numbers*
Since both the minuend and the subtrahend are signed, the subtraction
operation can be changed into an addition operation by taking the unary minus
(radix complement) of the subtrahend.
Nd=N1-N2=N1+(-N2)
This gives rise to the notion of a generalized addition operation. While
addition is accomplished by addition as usual, subtraction is accomplished by
adding the radix complement of the subtrahend.
Example 1.3.3.1:
Find Nd=N1-N2 where
N1=+53 and N2=-28 expressed in 8 bit
2s Complement representation.
Solution:
N1=001101012
N2=111001002
00011011
+ 1
-------------------------------------
-N2=000111002
Binary
Decimal
Carry
111
00110101
+53
+
00011100
+ -(-28)
01010001
Nd = +81
Nd=001101012-111001002=010100012
Example 1.3.3.2:
Find Nd=N1-N2 where N1=-28
and N2=+53 expressed in 8 bit 2s Complement representation.
Solution:
N1=111001002
N2=001101012
-N2=110010112
Binary
Decimal
Carry
1
11100100
-28
+
11001011
+ -(+53)
110101111
-81
Nd=111001002-001101012=101011112
Example 1.3.3.3:
Find Nd=N1-N2 where N1=+117
and N2=-92 expressed in 8 bit 2s Complement representation.
Solution:
N1=011101012
N2=101001002
-N2=010111002
Binary
Decimal
Carry
11 1
00110101
+117
+
01011100
+ -(-92)
11000001
?
+209
Nd=011101012-101001002=OVERFLOW
Since the numbers are signed, when subtracting the numbers, it is possible to
have an overflow condition.
Observations:
1. When subtracting two signed numbers together, if the result is negative, no carry will be generated.
2. If the result is positive, a carry will be generated. This carry must be discarded.
3. It is possible to have an OVERFLOW or UNDEFLOW condition. The OVERFLOW condition occurs when after the unary minus operation, two positive numbers are added together but the result is a negative sum. The UNDERFLOW condition occurs when after the unary minus operation, two negative numbers are added together but the result is a positive sum.
Exercise 1.3.3.1:
Find Nd=N1+N2 where N1=-92
and N2=-117 expressed in 8 bit 2s Complement representation.
Solution:
N1=101001002
0 0100100 1011011 + 1 = 1011100 =9210
N2=100010112
Binary
Decimal
Carry 1
10100100
-92
+
10001011
+ -(117)
100101111
Underflow
+209
Nd=011101012-101001002=UNDERFLOW
Since the numbers are signed, when subtracting the numbers, it is possible to
have an underflow condition.
Exercise 1.3.3.2:
Find Nd=N1-N2 where N1=-92
and N2=+117 expressed in 8 bit 2s Complement representation.
Solution:
N1=101001002
N2=011101012
-N2=100010112
Binary
Decimal
Carry 1
10100100
-92
+
10001011
+ -(117)
100101111
+209
Nd=011101012-101001002=UNDERFLOW
Since the numbers are signed, when subtracting
the numbers, it is possible to have an overflow or underflow condition.
Exercise 1.3.3.3:
Find Nd=N1-N2 where N1=-1
and N2=+117 expressed in 8 bit 2s Complement representation.
Solution:
N1=111111112
N2=011101012
-N2=100010112
Binary
Decimal
Carry 1
11111111
-1
+
10001011
+ -(117)
110001010
-118
Nd=011101012-101001002=100010102
Exercise 1.3.3.4:
Find Nd=N1-N2 where N1=+36
and N2=+117 expressed in 8 bit 2s Complement representation.
Solution:
N1=001001002
N2=011101012
-N2=100010112
Binary
Decimal
Carry
00100100
+36
+
10001011
+ -(117)
10101111
-81
Nd=011101012-101001002=101011112
Exercise 1.3.3.5:
Find Nd=N1-N2 where N1=+36
and N2=-11 expressed in 8 bit 2s Complement representation.
Solution:
N1=001001002
N2=111101012
-N2=000010112
Binary
Decimal
Carry
00100100
+36
+
00001011
+ -(-11)
00101111
+47
Nd=011101012-101001002=00101111
Exercise 1.3.3.6:
Find Nd=N1-N2 where N1=
-12and N2=+117 expressed in 8 bit 2s Complement representation.
Solution:
N1=100001002
N2=011101012
-N2=100010112
Binary
Decimal
Carry 1
10000100
-124
+
10001011
+ -(117)
100001111
+241
Nd=011101012-101001002=OVERFLOW
Positional Numbering System
Octal:
r=8
123.458=(1*82+2*81+3*80+4*8-1+5*8-2)10
Decimal:
r=10
123.4510=(1*102+2*101+3*100+4*10-1+5*10-2)10
Hexadecimal:
r=16
123.4516=(1*162+2*161+3*160+4*16-1+5*16-2)10
Rewrite 1110 in binary, octal, and hexadecimal 1110=10112=138=B16
Rewrite 1810 in binary, octal, and hexadecimal 1810=100102=228=1216
Rewrite 123.458 in
binary form.
123.458=001 010 011.100 1012
Rewrite 123.4516 in
binary form.
123.4516=0001 0010 0011.0100 01012

|
Binary |
Octal |
Hexadecimal |
Decimal |
Shorthand |
|
20 |
80 |
160 |
1 |
1 |
|
21 |
|
|
2 |
|
|
22 |
|
|
4 |
|
|
23 |
81 |
|
8 |
|
|
24 |
|
161 |
16 |
|
|
25 |
|
|
32 |
|
|
26 |
82 |
|
64 |
|
|
27 |
|
|
128 |
|
|
28 |
|
162 |
256 |
|
|
29 |
83 |
|
512 |
|
|
210 |
|
|
1024 |
1 K |
|
211 |
|
|
2048 |
|
|
212 |
84 |
163 |
4096 |
|
|
213 |
|
|
8192 |
|
|
214 |
|
|
16384 |
|
|
215 |
85 |
|
32768 |
|
|
216 |
|
164 |
65536 |
6K |
|
... |
... |
... |
... |
... |
|
220 |
|
165 |
1048576 |
1 M |
|
... |
... |
... |
... |
... |
|
230 |
810 |
|
|
1 G |
|
231 |
|
|
|
2 G |
|
232 |
|
168 |
|
G |