Number Systems (CSE)
Number Systems (CSE)
Thanks to
Dr. Arshad M. Chowdhury
What is Number System?
A number system defines a set of values used to represent
quantity.
104 103
10 10
6
5
102 10-2 10-3
101 10-1
100
aj : the coefficients
Subscript j : the place value
i= 0 to n (a i r i
) + j= 1 to m (a j r -j
)
Example : Base-r to Decimal Conversion
Octal to Decimal
(127.4)8 = 1x82 + 2x81 + 7x80 + 4x8-1 = (87.5)10
Hexadecimal to Decimal
(B65F)16 = 11x163 + 6x162 + 5x161 + 15x160 = (46687)10
Binary to Decimal
(110101)2 = 1x25 + 1x24 + 0x23 + 1x22 + 0x21 + 1x20 = (53)10
Base-5 to Decimal
(4021.2)5 = 4x53 + 0x52 + 2x51 + 1x50 + 2x5-1 = (511.4)10
Converting Decimal integer to any Base-r
General Rule
Simply repeat dividing the number and all successive
quotients by r and saving the remainder
(1) 105 / 2 = 52 1 1
(2) 52 / 2 = 26 0 01
(3) 26 / 2 = 13 0 001
(4) 13 / 2 = 6 1 1001
(5) 6/2= 3 0 01001
(6) 3/2= 1 1 101001
(7) 1/2= 0 1 1101001
So 105 in decimal is written as 1101001 in binary.
Converting Decimal to Octal
Simply repeat dividing by 8 and saving the remainder.
First remainder will be the last digit in the octal number
Second remainder will be the second digit from the right;
….. and so on.
First integer will be the fast digit from left after the radix
point, Second integer will be the second digit from the left
after radix point ….. and so on
Converting Decimal fraction number to Base-r
Example: convert (0.6875)10 to binary Base-2
(0.6875)10 = (0.1011)2
Conversion of Decimal number
with radix point to Base-r
Separate the integer and fraction part
Convert the integer and fraction point to Base-r number
separately
Combining the two answer
7 5 6 3 0 2 1
111 101 110 011 000 010 001
So 10110100111100101101001011 (binary)
= 2D3CB8B (hex)
= 264745513 (octal)
Converting from Hex to Binary
6 F 0 3 7 C 2
0110 1111 0000 0011 0111 1100 0010
Complements
Example:
Example:
Signed-magnitude representation:
The number consists of magnitude and sign bit
8-bit binary signed magnitude representation of +(9)10 is
(00001001 )2 and (-9)10 is (10001001 )2
The right bit of the result is placed under the column of bits. The left
bit is called the "carry out of the column".
1 1 1 1 0 0 0 0
0 0 1 1 1 0 1 0 1 0 1 0
0 1 0 1 1 1 0 0 1 1 0 0
--- --- --- --- --- --- --- --- --- --- --- ---
0 01 01 10 11 10 10 01 10 01 01 00
+6 00000110
+13 00001101
--------- ------------------
+19 00010011
Binary Number Subtraction
Similar to decimal system using borrowing:
Subtract one binary number from another by using the
standard techniques adapted for decimal numbers
(subtraction of each bit pair, right to left, "borrowing"
as needed from bits to the left).
Now, let's add them together: Since we've already defined our
number bit field as three bits
plus the negative-weight bit,
11111111 <--- Carry bits the fifth bit in the answer (1)
00000111 will be discarded to give us a
+ 11111011 result of 00102, or positive two,
------------- which is the correct answer.
100000010
|
Discard extra bit
.
. Answer = (00000010)
Binary Codes
An n-bit binary code is a group of n bits that assumes up to
2n distinct combinations of 1’s and 0’s with each combination
representing one element of set that is being coded
Example:
4 9
0100 1001 = 01001001BCD
41
Error Detecting Code - Parity Coding