S1 Teknik TelekomunikasiFakultas Teknik Elektro
FEH2H3 | 2016/2017
Boolean Algebra and Logic Series
CLO2-Week 6-Number System
Outline
• Able to convert number among number system (Binary, Octal, Decimal, and Hexadecimal)
• Able to present negative number in 1’s complement and 2’s complement form
• Able to solve summation and substraction based on complement number
• Able to present BCD number and floating point number
• Able to solve summation and substraction in various number system (Binary, Octal, Decimal, Hexadecimal, and BCD)
141
Binary, Octal & Hexadecimal Number (1)
• Binary Number: binary system is based on powers of 2, constituent figures numbers : 0 & 1
• Converstion Example Decimal to binary: 1410 = X2 , X= ?
143
Hence 1410= 11102
Binary, Octal & Hexadecimal Number (2)
• Decimal to binary conversion can also be done by
considering the weight of each decimal number '1' in every
position binary numbers.
144
• The number '1' inserted into the largest weighing
boxes still smaller than the remaining decimals
Binary, Octal & Hexadecimal Number (3)
• Octal Numbers: Based on number eight, the numbers
making up numbers: 0,1,2,3,4,5,6 & 7
• Hexadecimal Numbers: Numbers base 16, the numbers
making up numbers : 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E & F
• How converting decimal number to octal and hex basically
the same as converting into binary, but it needs to be
converted into a divider 8 and 16.
145
Binary, Octal & Hexadecimal Number (4)
• Examples of conversion binary, octal and hex to decimal
1. 1012 = 1*22 + 0*21 + 1*20 = 510
2. 288 = 2*81 + 8*80 = 1810
3. 1716 = 1*161 + 7*160 = 2310
146
Binary, Octal & Hexadecimal Number (5)
• Converting a binary number to octal (hexa)
1. For to octal (hexa), segment the binary number threes
(four-four), starting from the right. If a lot of bits is not a
multiple of 3 (4), plug in some numbers '0' on the left of the
number to be a multiple of 3 (4).
2. Converting each group to octal (hexa)
147
Binary, Octal & Hexadecimal Number (6)
• Example
1. Binary to Octal:
101102 = 0101102 = 010 | 110 = 2 | 6 = 268
2. Binary to Hexa:
101102 = 000101102 = 0001 | 0110 = 1 | 6 = 1616
• For the opposite conversion, the steps above to stay behind.
148
Binary, Octal & Hexadecimal Number (7)
Some terms in binary numbers:
• Bit: binary digit
• Nibble: 4 bits
• Byte: 8 bits
• MSB: most significant bit (leftmost bit, the greatest weight)
• LSB: least significant bit (rightmost bit, the smallest weight)
149
Binary Coded Decimal (BCD) (1)
• On the basis of the BCD system, one decimal point (0-9)
equivalent with the binary system of weighted 8-4-2-1
Used for the conversion Binary Decimal numbers can
still be easily understood by humans
150
• Other bit
scheme(1010,
1011, 1100, 1101,
1110, 1111) are
not used
Binary Coded Decimal (BCD) (2)
Example: 863.9810 = 1000 0110 0011.1001 1000BCD
(8) (6) (3) (9) (8)
Weigth: (800, 400, 200, 100)(80, 40, 20, 10)(8, 4, 2, 1)(0.8, 0.4,
0.2, 0.1)(0.08, 0.04, 0.02, 0.01)
151
XS3 BCD (3)
• Eccess 3 BCD (XS3 BCD/ XS3)
Binary numbers for the system is obtained by adding to the
number 00112 BCD base
XS3 = BCD + 00112
0
Ekivalen Desimal
Pola BitBCD
00110100 1
234
0101
5
Ekivalen Desimal
Pola BitBCD
01100111
10001001 6
789
101010111100
152
• Other bits
schemes (0000,
0001, 0010, 1101,
1110, 1111) are
not used
Negative Binary Number (1)
• Negative numbers required for arithmetic operations on
digital machines based on the sum. For reduction, a concept
that is used : A – B = A + (-B)
• Negative numbers are mathematically characterized by
administering a '-' in front of the number in question. In the
digital machine, generally negative numbers expressed in
three systems / ways
154
Negative Binary Number (2)
1. Sign Bit System: MSB = 0 for positive numbers and MSB = 1 for
negative numbers. Example (4-bit system):
+410 = 01002SM +0 = 00002SM
-410 = 11002SM -0 = 10002SM
Weakness
No number 'zero' is unique and requires a long time in the
operations of addition and subtraction. System Bit Markers
typically used in system Floating Point numbers
155
Negative Binary Number (3)
2. Radix Complement System / Base. For a number X AND
numbers, Complement Radix :
LSDX
XRX
R
RN
RC
1
X
01234567
BinerX
10
DesimalX
98765
HexaX
FEDCBA98
156
LSD: Least Significant DigitXR: Complement Number
Negative Binary Number (4)
2. Radix/Basis Complement System (continued)
Example:
1. 10's complement from 47,83 is equal to N10 + 1LSD = 52,17.
2. 2's complement from 0101101,101 is equal to N2 + 1LSD = 1010010,011.
3. 16's complement from A3D is equal to N16 + 1LSD = 5C2 + 1 = 5C3.
Note:
For the two bases, the above system is called 2’s Complement
157
Negative Binary Number (5)
• Basic reduction in negative numbers by means of 2's
Complement analogous to Odometer (estimator Mileage)
on motor vehicles. Suppose an Odometer have three-digit
numbers then Odometer they measure up to 1000km.
After reaching the number '999' next Odometer will be
back to 000.
158
Negative Binary Number (7)
3. Radix Complement System / Small Base
System are Radix Complement System / Base but without reduction 1LSD. The tables shown earlier is of this system
BinerX DesimalX HexaX
160
Deduced how to obtain small radix complement and complement regular radix
Negative Binary Number (8)
3. Radix Complement System / Small Base (continued)
For base 2: This system is called the 1's Complement (pair of 2's
complement)
For base 10: This system is called the 9's Complement (pair of
10's complement)
For base 16: This system is called 15's Complement (pair of 16's
complement)
161
Negative Binary Number (9)
162
3. Radix Complement System / Small Base (continued)
Base 2 example:
+710= 0000 01112 (8-bit system, focus on MSB)
-710= 1111 10002 (8-bit system, focus on MSB)
Negative Binary Number (10)
• When the numbers marked on the system width will be
treated with a certain bit width bit larger system then steps
are performed:
A. For positive numbers: fill in the blank (left) with '0' to all
unused bits.
B. For negative numbers: fill in the blank (left) with '1' to all
unused bits.
00012 (+110, 4 bit) = 0000 00012 (+110, 8bit)
10112 (-510, 4 bit) = 1111 10112 (-510, 8bit)
163
Fraction Number (1)
164
A. Converting fractions binary / hex to decimal
Every binary / hex on the right commas mean weight
(rank) of its negative
0,0112 = 0*20 +0*2-1 +1*2-2 +1*2-3 = 0 +0,2510 +0,12510
= 0,37510
0,1016 = 0*160 + 1*16-1 + 0*16-2 = 0 +0,062510 +0
= 0,062510
Fraction Number (2)
B. Converting decimal to binary fractions
0,X10 = 0,Y2
Y10 = 0,X10*2n; n: many binary digits to the right of the comma which are desired
Example
0,7510 = 0,Y2 ; wants four digits
Y10 = 0,7510* 24 = 0,7510*1610 = 1210 = 11002
0,7510 = 0,11002
165
Fraction Number (3)
C. Conversion of hexadecimal to decimal fractions
0,X10 = 0,Y16
Y10 = 0,X10*16n; n: many binary digits to the right of the comma which are desired
Example
0,7510 = 0,Y16 ; Y desired two-digit
Y10 = 0,7510* 162 = 0,7510*25610 = 19210 = C016
0,7510 = 0,C016
166
Fraction Number (5)
D. Converting binary fractions hexadecimal
Same way a conversion of binary integer hexadecimal
167
The IEEE standard for floating point arithmetic
• Standard for floating point representation in:single precision (32-bit)double precision (64-bit)
• Floating point format differences affect the floating point
computation .
168
Single Precision
• Single precision floating point standard representation 32 bit word, represented from 0 s / d 31, from left to right.
• The first bit is the sign bit (S), then the next 8 bits are the bits exponent (E), and the 23 remaining bits are fraction(F):
S EEEEEEEE FFFFFFFFFFFFFFFFFFFFFFF
0 1 8 9 31
169
Single Precision
• V-value is represented by the following word :
– If E = 255 and F is not 0 (nonzero), then V = NaN ("Not a number")
– If E = 255 and F is 0, and S = 1, then V = -infinity
– If E = 255 and F are 0 and S = 0, then V = Infinity
– If 0 <E <255 then V = (- 1) ^ S * 2 ^ (E-127) * (1.F) where "1.F" is intended to represent the binary number created by prefixing F with an implicit leading 1 and a binary point.
– if E = 0 and F is not 0 (nonzero), then V = (- 1) ^ S * 2 ^ (-126) * (0.F). This includes the value "un-normalized".
– if E = 0 and F = zero and S = 1, then V = -0
– if E = 0 and F = zero and S = 0, then V = 0
170
Double Precision
• The IEEE standard for double precision floating point representation requires a 64 bit word, 0 to 63, from left to right.
• The first bit sign bit, S, 11 bits subsequent exponent bits, 'E', and the remaining 52 bits is a fraction 'F'
172
Double Precision
• Value V is represented by a group of word that can be shown as follows:
– if E = 2047 and F = nonzero, then V = NaN ("Not a number")
– if E = 2047 and F = zero and S = 1, then V = -infinity
– if E = 2047 and F = zero and S = 0, then V = Infinity=
– If 0 <E <2047 then V = (- 1) ** S * 2 ** (E-1023) * (1.F) where "1.F" is intended to represent the binary number created by prefixing F with an implicit leading one and a binary point.
– If E = 0 and F = nonzero, then V = (- 1) ** S * 2 ** (-1022) * (0.F) This includes the "unnormalized" values.
– If E = 0 and F = zero and S = 1, then V = -0
– if E = 0 and F = zero and S = 0, then V = 0
173
Example
• The binary representation of - 0.75 in IEEE single precision format is as follows:
(-1) s x (1+M) x 2E
• Answer:
• decimal representation : - 0.75 = -3/4 = -3/22
• binary representation : - 0.75 = - 0.11 = -1.1 x 2-1
– (-1)s x (1 + M) x 2E
– Sign bit = 1
– (1+M) = (1+ .1000….)
– Exponent = (-1 + 127) = 126
Note: -1 obtained from the rank of rank 2-1 exponent is -1127 obtained from the bit length eksp 28-1-1 = 127
– So, : 10111111010000000000000000000000
174
Example 2
• -118.625 Binary representation of the IEEE single precision format is as follows :
(-1) s x (1+M) x 2E
• Answer :
• binary representation : - 118.625 = - 1110110.101
= - 1.110110101 x 26
– (-1)s x (1 + M) x 2E
– Sign bit = 1– (1+M) = (1+ .11011010100000000000000)
– Exponent = (6 + 127) = 133Note : 6 obtained from the rank of powered exponent 26 is 6
127 obtained from the bit length exponent 28-1-1 = 127– So : 11000010111011010100000000000000
175
Binary Summation & Substraction (1)
1. Direct Summation
• Add two binary numbers + can be done as a decimal (base
10). When the sum of two bits more than 012, a carry bit is
added to the next MSB; This process continues until all bits
are summed
176
Binary Summation & Substraction (2)
1. Directly Summation (continued)
Example: Addition of 8-bit binary number
177
Binary Summation & Substraction (3)
• Reduction of the 2's Complement: The most widely used in computing.
1310
710-0 11012
0 01112-0 11012
1 10012+== 710- dalam 2's Complement
0 011021
Bit Penanda: PositifOverflow dibuang
1710
310-0
11012001112
-0 01112
1 00112+== 1310- dalam 2's Complement
1 101020
Bit Penanda: NegatifOverflow dibuang
=
610+=
610-=
=
dalam 2's Complement
178
Binary Summation & Substraction (5)
• 1’s Complement Substraction (continued)
180
How to read the numbers with negative marker bit ('1') in the negative decimal numbers?
Binary Summation & Substraction (6)
• Summation BCD: Summation ranging from LSD and ending at MSD. If the sum exceeds 10012 (910) (including Overflow per number) be corrected by adding 01 102 (610). Carry (00012) is added to the next MSD.
05610
06910+0000 0101 0110BCD
0000 0110 1001BCD+
0000 1011 1111 0110 0110
Hasil penjumlahan
Koreksi
Carry
0001 0010 0101BCD
1 1 01 1111
Hasil: 12510
181
Binary Summation & Substraction (7)
• Reduction BCD: Done by making unfounded negative BCD 10's complement system (10C). If negative, the results should be negated back.
08,2510
13,5210-
0000 1000 , 0010 0101BCD
1000 0110 , 0100 1000BCD+
1000 1110 , 0110 1101 0110 , 0110
Hasil penjumlahan
Koreksi
Carry
1001 0100 , 0111 0011BCD10C
11
Hasil: 94,7310C
08,2510
86,4810C+
05,2710- 94,7310C+
11 1
182
Binary Summation & Substraction (7)
• Substraction BCD (continued)
Results +94,7310C to be negated by the 10's Complement
method to obtain correct results.
+94,7310C = - 05,2710
Conclusion
For binary addition and subtraction, 2's complement shows
the simplest steps.
2's complement is not necessarily the simplest to other
arithmetic operations (multiplication and division)
183