0% found this document useful (0 votes)
7 views52 pages

2 - ComputerOrganization - Data Rep

The document provides an overview of different positional number systems including denary, binary, hexadecimal, and octal, explaining their bases and digit ranges. It details how to convert between binary and denary systems, as well as the significance of binary representation in computers, including data types like ASCII and Unicode. Additionally, it covers logic gates and their functions in digital circuits, emphasizing the role of binary as a foundational language for computer systems.

Uploaded by

manitkhurana1105
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views52 pages

2 - ComputerOrganization - Data Rep

The document provides an overview of different positional number systems including denary, binary, hexadecimal, and octal, explaining their bases and digit ranges. It details how to convert between binary and denary systems, as well as the significance of binary representation in computers, including data types like ASCII and Unicode. Additionally, it covers logic gates and their functions in digital circuits, emphasizing the role of binary as a foundational language for computer systems.

Uploaded by

manitkhurana1105
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 52

Computer Organization

Different Positional Number Systems

• Denary - A digit in base 10 ranges from 0 to 9.


• Binary - A digit in base 2 ranges from 0 to 1.
A digit in base 2 is also called a ‘bit’.
• Hexadecimal - A digit in Base 16 can range
from 0 to 15 (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F).
• Octal - A digit in Base 8 can range from 0 to 7
• Generally, a digit in base R can range from 0
to R-1
Positional Number System – Denary (Base
10)
Positional values or Place values or weights
102 101 100 10-1 10-2 10-3

1 2 3 . 3 2 1

MSD Decimal LSD


point

The number is written as 123.32110


Positional Number System – Binary (Base 2)

22 21 20 2-1 2-2 2-3

1 0 1 . 0 1 1

MSB LSB

base point or radix

The number is written as 101.0112


What is Binary System?
• Binary generally represents 2 states – 0 or 1.
• Aim of binary system is to represent data in
these two states
• These two states are easily implemented as a
switch in a computer.
• 0 – OFF, FALSE
• 1 – ON, TRUE
• There are millions of switches in a computer to
switch between 0 and 1
Denary System concept
• Base 10 system.

100 = 1
101 = 10
102 = 100
103 = 1000
104 = 10000
• So a denary number 248 is expanded in Base 10
system as
2x102 + 4x101 + 8x100
Binary System concept
• Base 2 system
20 = 1
21 = 2
22 = 4
23 = 8
24 = 16
25 = 32 and so on
• So a binary number 110 is expanded in base 2
system as
1x22 + 1x 21 + 0x20
How to convert a binary number to denary?

• Example 1
• Binary 1110
0 x 20 = 0
1 x 21 = 2
1 x 22 = 4
1 x 23 = 8
Total = 14
Equivalent Denary Number = 14
How to convert a binary number to denary?
• Example 2
• Binary 101101010
0 x 20 = 0
1 x 21 = 2
0 x 22 = 0
1 x 23 = 8
0 x 24 = 0
1 x 25 = 32
1 x 26 = 64
0 x 27 = 0
1 x 28 = 256
Total = 256 + 64 + 32 + 8 + 4 + 2 = 362
How to convert a denary number to binary?
• We also follow successive or repetitive division by 2.
• This is more methodical.
• Example
• Take a denary number 245.
2| 245
2| Quotient 122 – Remainder 1
2| Quotient 61 – Remainder 0
2| Quotient 30 – Remainder 1
2| Quotient 15 – Remainder 0
2| Quotient 7 – Remainder 1
2| Quotient 3 – Remainder 1
2| Quotient 1 – Remainder 1
2| Quotient 0 – Remainder 1

Stop when the Quotient becomes 0


Take the remainders bottom up.
Fact
• Everything should be stored as binary in the
computer.
• Which means everything should be converted
to numbers
– Music
– Video
– Text like Abcd,&*(@
– Pictures
• Digital data comprises of binary numbers
Byte
• A binary digit is known as bit
• 8 bits are referred to as a Byte
• 4 bits make a Nibble
• The byte is the smallest unit of memory.
• With one byte, not much data can be stored.
• Usually data occupies multiple bytes.
Memory Sizes
Memory Size Number of bits Denary Value
1 Kilobyte 210 bytes 1024 bytes
1 megabyte 220 = 1000 KB 1048576 bytes
1 gigabyte 230 = 1000 MB 1073741824 bytes
1 terabyte 240 = 1000 GB 1099511627776 bytes
1 petabyte 250 = 1000 TB 1125899906842624 bytes
1 exabyte 260
1 zettabyte 270
1 yottabyte 280
Hexadecimal
• It is similar to binary system.
• Base 16 system
• 16 different values are required to represent a digit
• 0 1 2 3 4 5 6 7 8 9 A B C D E F are used
• Where A = 10, B =11, C=12, D=13, E= 14, F=15
160 = 1
161 = 16
162 = 256
163 = 4096
164 = 65536
• Since 16 = 24 , each hex digit requires 4 binary digits
Denary Binary Hex
0 0000 0
1 0001 1
2 0010 2
3 0011 3
4 0100 4
5 0101 5
6 0110 6
7 0111 7
8 1000 8
9 1001 9
10 1010 A
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F
Why Hexadecimal System?
• What does a Base 16 number system have to do
with a machine that's based on zeros and ones?
• Long before programmers regularly used a
convenient method to handle large binary
numbers in either 3-bit (octal) or 4-bit
(hexadecimal) groupings.
• Ease of display – saving screen space and paper
• Conversion from hex to binary and vice versa is
easier
Converting from Binary to Hex
• Example
1111100001
• Start from right and split into 4 bits
11 1110 0001
0011 1110 0001
3 E 1
Converting from Hex to Binary
• Example 45A
4 5 A
0100 0101 1010
Equivalent Binary is 10001011010
• Example BF08
B F 0 8
1011 1111 0000 1000
Equivalent Binary is 1011111100001000
Converting hex numbers to denary
• Example 45A
• Can be expanded as
• 4x162 + 5x161 + Ax160 (A is 10)
• Which is
• 1024 + 80 + 10 = 1114
Converting denary numbers to hex –
Method 1
• Trial and Error method
4096 256 16 1
7 D 4 = 2004
(D is 13)
Converting denary numbers to hex –
Method 2
• Repetitive division method by 16
16| 2004
16| Quotient 125 – Remainder 4
16| Quotient 7 – Remainder 13
Quotient 0 – Remainder 7

• Stop when the Quotient becomes 0


• Take the remainders bottom up.
• 2004 in denary = 7D4 in hex
Hexadecimal - Memory dump
• Hexadecimal uses
– Memory dumps
– Error codes
– HTML color codes
Data representation in the computer
• Computer work with the binary number system, so
everything in them is represented in 1s and 0s.
• So, the data that we want to store in the computer
needs to be encoded in 1s and 0s.
• TEXT
• Text needs to be also transformed into 0s and 1s.
• To do this, a character set is used.
• A character set is a collection of characters and the
binary codes that represent them.
• Today, the most used character sets are ASCII and
Unicode.
Data representation in the computer
• ASCII: stands for American Standard Code for Information
Interchange. It uses 7 (later 8) bits to encode the characters,
so in total 28=256 different characters can be represented.
• Unicode: is a superset of ASCII. It was developed because
people realized that the 256 characters of ASCII are not
enough to satisfy our need for a suitable number of
characters. It uses upto 32 bits to encode the characters.
• Advantages
– Data corruption is eliminated
– The product can get support in many platforms, countries
– Cost savings
• UTF-8 (Variable length), UTF-16(Variable length), UTF-32(Fixed length) variants
are present
• Strings: representation of characters in a continuous bit
chain
Data representation in the computer
• Integers: representation of numbers in computers.
(Whole numbers)
• Unsigned Integers
– Covers only positive numbers
– For example - 8 bits 28 = 256 (0 to 255 can be represented)
• Signed Integers
– Covers both positive and negative numbers
– For example – 8 bits 28 = 256 ( -128 to + 127 can be
represented)
– Negatives can be represented by the two's complement
method.
Two’s complement
• Assume that an 8-bit register needs to store positive as
well as negative numbers
• Positive Range would be 0 to 127 (total 128 numbers)
• Negative Range would be -1 to – 128 (total 128 numbers)
• Positive numbers can be stored in this register by directly
converting to binary
• Negative numbers will be represented in two’s
complement form
• The MSB will take a negative place value as shown below.
Two’s complement – Short cut method
• How to find
– Take the binary for the positive equivalent
– Revert the bits and add 1 to the LSB
– MSB determines whether the number is positive
or negative
Two’s Complement
• Normal Binary form for Positive Number (True form)
• Two’s complement form for negative number
• It is calculated by adding 1 to 1’s complement.
• 1’s complement of 0110 = 1001
• 2’s complement of 0110 = 1
-------------------
1010
Binary addition rules are 0+0=0
0+1=1
1+0=1
1 + 1 = 10
1 + 1 + 1 = 11
Two’s complement Binary
0111
Decimal
+7
• Consider 4 bit register 0110 +6
0101 +5
1. There is one unique 0 0100 +4
2. The 2’s complement of 0 is 0 0011 +3
3. The leftmost bit actually represents 0010 +2
whether a number is negative and 0001 +1
positive, 0 – positive, 1 – negative 0000 0
4. 2’s complement of a negative number is 1111 -1
positive number 1110 -2
1101 -3
1100 -4
1011 -5
1010 -6
1001 -7
1000 -8
TOK - Does binary represent an example of
a lingua franca?
• Lingua Franca – a shared language of communication used by people
who are speakers of different languages.
• Standard Language: foundational language for all computers and digital
devices. Regardless of the hardware or software, universally understood
by digital systems.
• Interoperability: allows different systems and devices to communicate
and operate together seamlessly. Just as a lingua franca facilitates
communication between people of different native languages.
• uses only two symbols (0 and 1), making it a simple and efficient way to
represent and process information. parallels how a lingua franca often
uses simplified vocabulary and grammar to ease communication.
• unambiguous way to represent instructions and data.
Data representation in the computer
• Colours
– Red, Green and Blue are the primary colors
– All the other colors are generated by the varying intensity of these
three colors.
– Each primary color is represented by 8 bits giving 256 different
intensities.
– Each color is represented by 24 bits (8x3) giving 16.7 Million color
shades.
– Since representing each color by 24 bits is cumbersome, it is
converted to Hex numbers.

http://www3.ntu.edu.sg/home/ehchua/programming/java/
datarepresentation.html
Introduction

e rsta nd t h is  Understand this 


Und
d e v i c e t h at • Logic gates serve as the
• Gate - A a s ic
r m s a b building blocks to digital
perfo
on
operation logic circuits using
c t r i ca l si g nals combinational logic.
e le a re
- G a t e s
• Circuits p e r form
• Logic gates basically
e d to
combin ted
process signals which
co m p l i c a represent true or false or
more
tasks the equivalent i.e. ON or
OFF, 1 or 0
Introduction

• Basic Gates
• 1. NOT gate
• 2. AND gate
• 3. OR gate
• 4. NAND gate
• 5. NOR gate
• 6. XOR gate.
• Logic diagram - A graphical representation of a
circuit
– Each type of gate is represented by a specific
graphical symbol
• Truth table - A table showing all possible input
values and the associated output values
Symbols Used
NOT GATE
• A NOT gate accepts one input value and
produces one output value

• A NOT gate is sometimes referred to as an


inverter because it inverts the input value
AND GATE
• An AND gate accepts two or more input
signals
• If all the input values for an AND gate are 1,
the output is 1; otherwise, the output is 0
OR GATE
• If all the input values are 0, the output value is
0; otherwise, the output is 1
• If one of the input values is 1, the output is 1
NAND GATE
• The NAND gate is the opposite of the AND
gate
• AND - NOT combination
NOR GATE
• The NOR gate is the opposite of the OR gate
• OR - NOT combination
XOR GATE
• exclusive OR gate
• An XOR gate produces 0 if its two inputs are the
same, and a 1 otherwise
• The output is true only when the inputs are
opposite of each other
• When both input signals are 1, the OR gate
produces a 1 and the XOR produces a 0
• Logical Expression for XOR gate is A  B or A.B + A.B
Basic Theorems

• Fundamental laws
• If X ≠ 0 then X = 1
• If X ≠ 1 then X = 0
• OR Relations
– 0+0=0
– 0+1=1
– 1+0=1
– 1+1=1
• AND Relations
– 0.0=0
– 0.1=0
– 1.0=0
– 1.1=1
• Complement Rules
– 0=1
– 1=0
Basic Theorems
• 0+X=X
• 1+X=1
• 0.X=0
• 1.X=X
• X+X=X
• X.X=X
• X’’ = X

• Precedence is NOT, AND, OR


Producing the truth table from a given logic
network
• Consider the following logic network which
contains three inputs and three logic gates:
• Deduce S, Deduce T and finally X
Designing logic networks to solve a specific
problem and testing using
truth tables
• Consider the following problem:
• “If button A or button B is on and button C is
off then the alarm X goes on”
• We can convert this into logic gate
terminology (ON = 1 and OFF = 0):
• If (A = 1 OR B = 1) AND (C = 0) then (X = 1)
Example
• A steel rolling mill is to be controlled by a logic network made up of AND, OR and NOT
gates only. The mill receives a stop signal (i.e. S = 1) depending on the following input
bits:

• A stop signal (S = 1) occurs when:


• Either Length, L > 100 meters and Velocity, V < 10 m/s
• Or Temperature, T < 1000 C and Velocity, V > 10 m/s

• Draw a logic network and truth table to show all the possible situations when the stop
signal could be received.
Example
• The first thing to do is to try and turn the question into a series of logic gates and
then the problem becomes much simplified.

• The first statement can be re-written as: (L = 1 AND V = NOT 1) since Length > 100
meters
• corresponds to a binary value of 1 and Velocity < 10 m/s corresponds to a binary
value of 0 (i.e. NOT 1).

• The second statement can be re-written as (T = NOT 1 AND V = 1) since


Temperature < 1000C
• corresponds to a binary value of 0 (i.e. NOT 1) and Velocity > 10 m/s corresponds
to a binary value of 1

• Both these statements are joined together by OR which gives us the logic
statement:

• if (L = 1 AND V = 0) OR (T = 0 AND V = 1) then S = 1


Given a truth table, how to get the logical
expression
A B C X Consider only the terms
(output) where the outputs are 1.
0 0 0 0 In this example, Row 2 and 7
0 0 1 1 Write the equivalent expression
0 1 0 0 For the terms separately using AND
0 1 1 0
1 0 0 0 For Row 2
1 0 1 0 A’.B.’C
1 1 0 1 (Note - 0 gets a dash, 1 as it is)

1 1 1 0 For Row 7
A.B.C’

Combine with OR
X = A’.B’.C + A.B.C’
TOK – Reason as a way of knowing
• involves the use of logic and rational thinking
to derive knowledge, make decisions, and
solve problem.
• Logic is formed in terms of circuits.
• There are only 2 answers – Yes or No. There
are no partial answers.
• Clarity and Precision in conclusions or
decisions

You might also like