Sei sulla pagina 1di 37

Number System and Logic Gates

Prepared by:
Engr.Abdul Kadar Muhammad Masum Lecturer in IT
Department of Business Administration International Islamic University Chittagong (Dhaka Campus) Cell: 01911024003, Email: akmmasum@yahoo.com

Number System:
In mathematics, a Number System is a set of numbers together with one or more operations, such as addition or multiplication. In computer literacy: Binary Number system, Decimal Number System, Octal Number System, Hexadecimal Number System are most prominent.
Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC 2

Bases of binary, decimal, octal and hexadecimal numbers system:

Name Binary Number system Decimal Number System Octal Number System Hexadecimal Number System

Base 2 10 8 16

Numbers 0,1 0,1,2,3,4,5,6,7,8,9 0,1,2,3,4,5,6,7 0,1,2,3,4,5,6,7,8,9,A, B, C, D, E, F

Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC

Binary Numbers
A single bit can represent two possible states, like a light bulb that is either on (1) or off (0) Combinations of bits are used to store values

Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC

Bit Combinations
1 bit 0 1 2 bits 00 01 10 11 3 bits 000 001 010 011 100 101 110 111 4 bits 0000 1000 0001 1001 0010 1010 0011 1011 0100 1100 0101 1101 0110 1110 0111 1111

Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC

How Computers Represent Data - Bits and Bytes


A single unit of data is called a bit, having a value of 1 or 0. Computers work with collections of bits, grouping them to represent larger pieces of data, such as letters of the alphabet. Eight bits make up one byte. With one byte, the computer can represent one of 256 different symbols or characters.

Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC

1 0 1

1 0

1 0 1

0 1 0 1 1
7

Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC

Binary, Octal, Hexa-decimal and decimal numbers up to 20


Decimal 000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 Octal 000 001 002 003 004 005 006 007 010 011 012 013 014 015 016 017 020 021 022 023 024 Hex 000 001 002 003 004 005 006 007 008 009 00A 00B 00C 00D 00E 00F 010 011 012 Binary 0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111 10000 10001 10010 10011 10100

Engr.Abdul Kadar Md. Masum, 013 Lecturer in IT, DBA, IIUC


014

Number System Conversion Methods:

Binary to Decimal: 11101102 = ? 1110110 = 1*26 +1*25 +1*24 +0*23 +1*22 +1*21 +0*20 = 64+ 32+16+0+4+2+0 =11810
Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC

Decimal to Binary Number System: 11810 = ?


Operation Remainder 118 2 = 59 0 59 2 = 29 1 29 2 = 14 1 14 2 = 7 0 72=3 1 32=1 1 12=0 1 Reading the sequence of remainders from the bottom up gives the binary numeral 11101102 (11810).
Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC 10

Hexa decimal to Decimal Number System

73D516 = ?? 73D516 =7*163+3*162+13*161+5*160 = 7*4096+3*256+13*16+5*1 = 28672+768+208+5 = 2965310

Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC

11

Decimal to Hexa-Decimal Number System:


Operation 29653 16 = 1853 1853 16 = 115 115 16 = 7 7 16 = 0 Remainder 5 13=D 3 7

Reading the sequence of remainders from the bottom up gives the hexa Decimal number is 73D516
Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC 12

Octal to Decimal Number System: 7038= ??

703 = 7 * 8 2 + 0 * 81 + 3 * 8 0 = 7 * 64 + 0 + 3 = 448 + 0 + 3 = 451


7038=45110
Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC

13

Decimal to Octal Number System: 451=??


Operation 451 8 = 56 56 8 = 7 7 8 = 0 Remainder 3 0 7

Reading the sequence of remainders from the bottom up gives the Octal numeral 7038
Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC 14

Conversion from any Base to any Base:

Say we have convert Octal number to Binary system. First: We will convert the octal number into Decimal number Second: We will convert the Decimal number into Binary number

Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC

15

Binary Addition:
Here 0+00 0+11 1+01 1 + 1 0, carry 1 Adding two "1" digits produces a digit "0", while 1 will have to be added to the next column. This is similar to what happens in decimal : 5 + 5 0, carry 1 (since 5 + 5 = 0 + 1 10) 7 + 9 6, carry 1 (since 7 + 9 = 6 + 1 10) This is known as carrying. Carrying works the same way in binary
Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC 16

Binary Addition:

11111 01101 +10111 ------------=100100

(carried digits)

10011 11001 +10011 ------------=101100

Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC

17

Binary Subtraction:
Subtraction works in much the same way: 000 0 1 1, borrow 1 101 110 Subtracting a "1" digit from a "0" digit produces the digit "1", while 1 will have to be subtracted from the next column. This is known as borrowing.
Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC 18

Binary Subtraction:
* *** 1101110 10111 ---------------= 1010111 ** * ** 1001100 10011 ---------------= 111001
(starred columns are borrowed from)

(starred columns are borrowed from)

Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC

19

Binary Multiplication:

Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC

20

Binary Multiplication:

Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC

21

ASCII:

Information Interchange.

ASCII stands for American Standard Code for

Each ASCII character is represented by 7 bits. 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. For Example: the Character A has the ASCII value 65. The binary equivalent of 65 is 1000001.
Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC 22

ASCII: (cont.)
One additional bit is needed to indicate whether the value is negative or positive. If the value is positive the additional bit is 0, otherwise it is 1. Hence the memory representation of the Character A will be as follows: A=65=1000001

Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC

23

ASCII: (cont.)

Any Character or digit we press from the keyboard is : Firstly, converted to a unique value (called ASCII value). Secondly, The computer then converts this value into its equivalent binary code and store in the memory.

Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC

24

Binary-Coded Decimal (BCD):


In BCD, a digit is usually represented by four bits which, in general, represent the values/digits/characters 0-9.
Decimal: 0 1 2 3 4 5 6 7 8 9 BCD: 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001

Thus, the BCD encoding for the number 127 would be: 0001 0010 0111

Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC

25

Alphanumeric Code:
In computing, an alphanumeric code is a series of letters and numbers which are written in a form that can be processed by a computer. In Alphanumeric character have meaning: "a"-"z", "A"-"Z", "0"-"9". No special characters are included. In computing terminology, a character stored in alphanumeric form is considerably smaller than storing a 8-bit ASCII character, as each character is only 6 bits in length
Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC 26

Logic gate:
Logic gates are electronic circuit, which operates on one or more inputs signal to produce an output signal.

x+y (x+y) y

y
Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC 27

Types of logic gates:


There are two types of gates: (a) Primary gate / Basic gates and (b) Secondary gate. Primary gets are three types. (1) OR gate (2) AND gate (3) NOT gate. Secondary Logic Gate: Some secondary gates are NAND, NOR, XOR, XNOR etc
Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC 28

OR Gate An OR gate has more than one input and one output. Its output is 1 , if any of its inputs is 1, otherwise 0. Ideal output, Z=X+Y, where + denotes OR operation. Gate truth table:
x
Gate symbol

y 0 1 0 1

z=x+y 0 1 1 1
29

0 0 1
Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC

x y

x y

AND Gate An AND gate has more than one input and one output. Its output is 1 , if all of its inputs are 1, otherwise 0. Ideal output, Z=X.Y, where . denotes AND operation.
Gate truth table:

x
Gate symbol

y 0 1 0 1

z=x.y 0 0 0 1
30

0 0 1
Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC

NOT Gate: A NOT gate has one input and one output. Sometimes called an inverter. Here output Y= , where - indicates NOT operation.
Gate truth table: Gate symbol

x 0 1
Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC

x 1 0
31

NAND Gate:
A NAND gate has same effect as an AND gate follow by NOT gate. Hence the output will be opposite of the AND gate. Ideal output, where . denotes AND operation and denotes the NOT operation.
A
Gate Symbol Gate Truth table

0 0 1 1 Engr.Abdul Kadar Md. Masum,


Lecturer in IT, DBA, IIUC

0 1 0 1

1 1 1 0
32

NOR Gate: A NOR gate has same effect as an OR gate follow by NOT gate. Hence the output will be opposite of the OR gate. Ideal output, where + denotes OR operation and denotes the NOT operation. Gate Truth table
A
Gate Symbol

0 0 1 1 Engr.Abdul Kadar Md. Masum,


Lecturer in IT, DBA, IIUC

0 1 0 1

1 0 0 0
33

XOR Gate: An EXOR gate is widely used in digital circuits. XOR is not a primary or basic gate. Here output , where denotes XOR gate.
Gate Truth table

A
Gate Symbol

0 0 1 1

0 1 0 1

0 1 1 0
34

Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC

XNOR Gate:
Here output Q = A B, where denotes XOR gate.
Gate Truth table

Q = AB

Gate Symbol

Q = AB

0 0 1 1

0 1 0 1

1 0 0 1
35

Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC

Summary
Summary for all 2-input gates Inputs A B AND NAND Output of each gate OR NOR XOR XNOR

0 0 1 1

0 1 0 1

0 0 0 1

1 1 1 0

0 1 1 1

1 0 0 0

0 1 1 0

1 0 0 1
36

Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC

Engr.Abdul Kadar Md. Masum, Lecturer in IT, DBA, IIUC

37

Potrebbero piacerti anche