0% found this document useful (0 votes)
105 views42 pages

Number Systems (CSE)

The document discusses different number systems including: 1) Roman, decimal, binary, octal, and hexadecimal number systems. It explains how each system uses different symbols and bases to represent quantities. 2) Converting between number systems such as decimal to binary involves repeatedly dividing by the base and recording the remainders. 3) Binary arithmetic includes concepts like complements which are used to simplify subtraction and logical operations in binary. Signed binary numbers also allow representation of positive and negative values.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views42 pages

Number Systems (CSE)

The document discusses different number systems including: 1) Roman, decimal, binary, octal, and hexadecimal number systems. It explains how each system uses different symbols and bases to represent quantities. 2) Converting between number systems such as decimal to binary involves repeatedly dividing by the base and recording the remainders. 3) Binary arithmetic includes concepts like complements which are used to simplify subtraction and logical operations in binary. Signed binary numbers also allow representation of positive and negative values.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 42

Number Systems

Thanks to
Dr. Arshad M. Chowdhury
What is Number System?
A number system defines a set of values used to represent
quantity.

Quantifying values and items in relation to each other is helpful


for us to make sense of our environment.
Roman Number System
The Romans devised a number system which could
represent all the numbers from 1 to 1,000,000 using only
seven symbols
I=1
V=5
X = 10
L = 50
C = 100
D = 500
M = 1000
A small bar placed above a symbol indicates the number is
multiplied by 1000.
The Decimal Number System
•The primary number system used is a base ten number
system.
•Base ten number systems are called decimal number
systems. - ten numerals, 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.

104 103
10 10
6
5
102 10-2 10-3
101 10-1
100

9735 = (9 * 103) + (7 * 102) + (3 * 101) + (5 * 100).


General Rule of Number Representation

A number with a decimal point is represented by a series


of coefficients:
a5a4a3a2a1a0 . a-1a-2a-3

aj : the coefficients
Subscript j : the place value

In decimal (base 10): The coefficients aj are any of the 10 digits 0,


1, 2, 3, 4, 5, 6, 7, 8, 9
Different Number Systems
Octal Number ystem (base 8)

Number system with only eight numerals : 0, 1, 2, 3, 4, 5, 6, 7

 Hexadecimal number system (base 16)

Number system with sixteen numerals : 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 , A,


B, C, D, E, F

 Binary Number System (base 2)

Number system with only two numerals : 0 and 1


Number Conversion
From any base or Radix r to Decimal or base10

A number expressed in base or Radix r system


can be converted to Decimal by applying the
follwing formula:

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

 First remainder will be the fast digit from right, Second


remainder will be the second digit from the right ….. and
so on
Converting Decimal to Binary
 Simply repeat dividing by 2 and saving the remainder.
 First remainder will be the last digit in the binary number, Second
remainder will be the second digit from the right; ….. and so on

Step Divide Equals Remainder Digits

(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.

Step Divide Equals Remainder Digits


(1) 3034 / 8 = 379 2 2
(3) 379 / 8 = 47 3 32
(5) 47 / 8 = 5 7 732
(6) 5/8= 0 5 5732

So 3034 in decimal is written as 5732 in Octal


Converting Decimal to Hex
 Simply repeat dividing by 16 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.
Conversion of 16242 from decimal to hex

Step Divide Equals Remainder Digits

(1) 16242 / 16 = 1015 2 = 2 (hex) 2


(2) 1015 / 16 = 63 7 = 7 (hex) 72
(3) 63 / 16 = 3 15 = F (hex) F72
(4) 3 / 16 = 0 3 = 3 (hex) 3F72

So 16242 in decimal is written as 3F72 in hex.


Converting Decimal fraction number to Base-r
General Rule

 Simply repeat multiplying the number and all successive


fractions by r and saving the integer parts.

These integer parts will be the coefficient of the Base-r


number

 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

Integer Fraction Coefficient

0.6875 x 2 = 1.3750 1 + 0.3750 a-1 = 1

0.3750 x 2 = 0.7500 0 + 0.7500 a-2 = 0

0.7500 x 2 = 1.5000 1 + 0.5000 a-3= 1

0.5000 x 2 = 1.000 1 + 0.000 a-4= 1

(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

Example : conversion of (105.6875)10 to Binary


Separate the Integer and Fraction parts
(105.6875)10 = (105)10 + (0.6875)10

Convert Integer and Fraction part to Base-r number separately


(105)10 = (1101001)2 as discussed before
(0.6875)10 = (1011)2 as discussed before

Combining the two answers radix point


(105.6875)10 = (1101001.1011)2
Converting Between Hex, Octal and Binary
Decimal (base 10) Binary (base 2) Octal (base 8) Hexadecimal (base 16)
00 0000 00 0
01 0001 01 1
02 0010 02 2
03 0011 03 3
04 0100 04 4
05 0101 05 5
06 0110 06 6
07 0111 07 7
08 1000 10 8
09 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
Converting from Binary to Octal
Simply by taking the binary digits in groups of three
(from right to left) and converting to each group to Octal.

Consider the binary number


10110100111100101101001011

If we take the digits in groups of three from right to left and


convert, we get:

10 110 100 111 100 101 101 001 011


2 6 4 7 4 5 5 1 3
10110100111100101101001011 (bin) is 264745513
Converting from Octal to Binary

Since each octal digit can be expressed in exactly three


binary digits, all we have to do is convert each octal digit to
three binary digits.

Converting 7563021 in octal to binary goes as follows:

7 5 6 3 0 2 1
111 101 110 011 000 010 001

So 7563021 (octal) is 111101110011000010001 (binary.)


Converting from Binary to Hex
Hex is base 16 and 16 is 24. That is, it takes exactly four binary
digits to make a hex digit

By taking binary digits in groups of four (right to left) we can


convert binary to hex.

Consider once more the binary number


10110100111100101101001011. By grouping in fours and
converting, we get:

10 1101 0011 1100 1011 0100 1011


2 D 3 C B 8 B

So 10110100111100101101001011 (binary)
= 2D3CB8B (hex)
= 264745513 (octal)
Converting from Hex to Binary

Simply write each hex digit as four binary digits.

In this way we can convert 6F037C2:

6 F 0 3 7 C 2
0110 1111 0000 0011 0111 1100 0010

Since we can drop the leading zero,

6F037C2 (hex) is 110111100000011011111000010 (binary).


Binary Arithmetic

Complements

Signed Binary numbers

Binary addition, subtraction and Multiplication


Complements
Used to simplify the subtraction operation and logical manipulations
Simplifying operations lead to simpler, less expensive circuits

Two types of Complements:


Radix Complement : ( r’s complement)
Diminished radix complement : (r-1)’s complement

Diminished Radix Complement:

Given a number N having n digits in Base -r

the (r-1)’s complement of N is: (rn – 1) - N

Example:

9’s complement of 246700 is 999999 – 246700 = 753299

1’s complement of 1101100 is 1111111 – 1101100 = 0010011


Radix Complement:

Given a number N having n digits in Base -r

the r’s complement of N is: rn – N for N  0


= (rn –1) – N +1
= (r-1)’s complement + 1

Example:

10’s complement of 246700 is = 9’s complement of 246700 + 1


= ( 999999 – 246700 ) + 1
= 753299 + 1
= 753300

2’s complement of 1101100 is = 1’s complement of 1011000 + 1


= (1111111 – 1101100 ) +1
= 0010011 + 1
= 0010100
Signed and Unsigned Number
Binary numbers with only two symbols, 0 and 1.
No minus sign (-) to represent negative numbers in Binary
Both signed and unsigned number consist of a string of bits when
represented in a computer
 User determine whether the number is signed or unsigned

Unsigned number: The leftmost bit is the most significant bit


of the number
Signed number: The leftmost bit is the sign bit and rest
represents the number

Sign Bit: bit placed in the leftmost position of the number.


Conventionally
0 : indicate the positive number
1: indicate the negative number
Signed Binary Integers

Three ways to represent negative binary numbers.

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

Signed 1’s complement representation:


Taking 1’s complement of the positive number including the sign bit
8-bit binary signed 1’s complement representation of -(9)10 is
(11110110)2

Signed 2's complement representation:


Taking 2’s complement of the positive number including the sign bit
8-bit binary signed 2’s complement representation of -(9)10 is
The Binary Number Addition
To add two 1-bit (representations of) integers: Count the number of
ones in a column and write the result in binary.

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).

Subtraction by adding with two’s complement:

Represent negative binary numbers by using the


"two's complement" method and a negative place-
weight bit. Here, we'll use those negative binary
numbers to subtract through addition.
Subtraction: 710 - 510
Addition equivalent: 710 + (-510)

Represent (+7)10 and (-5)10 in binary 2's complement form

So, in 8-bit binary representation,


+(7)10 = (00000111)2 and (-5)10 = (11111011)2

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

The bit combination of an n-bit code is determined from the


count in binary 0 to 2n -1

Example:

A set of 8 elements can be coded with 3-bit binary codes


(as 8 = 23) with each element assigned one of the following bit
combinations:
000, 001, 010, 011, 100, 101, 110, 111
Nibble: In computers and digital technology, a nibble
is four binary digits or half of an eight-bit byte.

Maximum number in a nibble :


(1111)bin = (15)dec = (F) hex
A nibble can be conveniently represented by one
hexadecimal digit.

Byte: A byte is eight binary digits (or bits)

One byte = 8 bits = 2 nibbles


Maximum number in a byte :
(11111111)bin = (255)dec = (FF) hex
BCD: Binary-coded decimal
A method of using binary digits to represent the decimal digits 0 through 9. A decimal digit is represented by four binary digits, as shown below:

The binary combinations


1010 to 1111 are invalid and
are not used in BCD
BCD Conversion
BCD and binary are not the same.
For example, 4910 in binary is 1100012,

but 4910 in BCD is 01001001BCD

4 9
0100 1001 = 01001001BCD

Each decimal digit is converted to its binary equivalent.


Similarly,
(185)10 = ( 0001 1000 0101)BCD = (10111001)2

(212)10 = ( ? )BCD = (?)2


BCD Addition
Example 1:
4 0100 Represent in BCD
+5 +0101 Represent in BCD
9 1001 BCD SUM

(9)10 = (1001)BCD = (1001)2


Example 2:
1 carry 1 carry
184 0001 1000 0100 in BCD
+ 576 +0101 0111 0110 in BCD
0111 10000 1010 Binary sum for each BCD

+0110 +0110 Add 6 if sum is above 1001


760 0111 0110 0000 BCD SUM

(760)10 = (0111 0110 0000)BCD = (1011111000)2


Other Decimal Codes
Weighted

Decimal Digit BCD


8421 2421 8,4,-2,-1 Excess-3
0 0000 0000 0000 0011
1 0001 0001 0111 0100
2 0010 0010 0110 0101
3 0011 0011 0101 0110
4 0100 0100 0100 0111
5 0101 1011 1011 1000
6 0110 1100 1010 1001
7 0111 0111 1001 1010
8 1000 1110 1000 1011
9 1001 1111 1111 1100
Self Complementing
Gray Code: A Gray code is an encoding of numbers so that
adjacent numbers have a single digit differing by 1

Decimal Number Gray Code


0 0000
1 0001
2 0011
3 0010
4 0110
5 0111
6 0101
7 0100
8 1100
9 1101
10 1111
11 1110
12 1010
13 1011
14 1001
15 1000
ASCII Code
ASCII, pronounced "ask-key", is the common code for
microcomputer equipment. The standard ASCII
character set consists of 128 decimal numbers ranging
from zero through 127 assigned to letters, numbers,
punctuation marks, and the most common special
characters.

The Extended ASCII Character Set also consists of


128 decimal numbers and ranges from 128 through 255
representing additional special, mathematical, graphic,
and foreign characters.
The Standard ASCII character set is divided into four
groups of 32 characters.
 

The first 32 characters,


characters form a special set of non-
printing characters called the control characters. We call
them control characters because they perform various
printer/display control operations rather than displaying
symbols.
Examples of common control characters include:
•carriage return which positions the cursor to
the left side of the current line of characters,
•line feed which moves the cursor down one
line on the output device
•back space which moves the cursor back one
position to the left

Unfortunately, different control characters perform


different operations on different output devices. There is
very little standardization among output devices. To find
out exactly how a control character affects a particular
device, you will need to consult its manual.
The second group of 32 ASCII character codes
comprise various punctuation symbols, special
characters, and the numeric digits. The most notable
characters in this group include the:
•space character
•numeric digits 0 through 9

Note that the numeric digits differ from their numeric


values only in the high order nibble. By subtracting
30h from the ASCII code for any particular digit you
can obtain the numeric equivalent of that digit.
The third group of 32 ASCII characters is
reserved for the upper case alphabetic characters.

The ASCII codes for the characters "A" through "Z"


lie in the range 41h through 5Ah. Since there are
only 26 different alphabetic characters, the
remaining six codes hold various special symbols.

The fourth, and final, group of 32 ASCII


character codes are reserved for the lower case
alphabetic symbols, five additional special symbols,
and another control character (delete).
ASCII Character Codes

41
Error Detecting Code - Parity Coding

Parity bit: A parity bit is an extra bit included with a


message to make the total number of 1’s either even or odd

Original message bits With even parity with odd parity

1000001 01000001 11000001

1010100 11010100 01010100

Parity bit helps to detect error during the transmission of information

You might also like