0% found this document useful (0 votes)
22 views69 pages

BCS Chapter 3

lecture

Uploaded by

Getu Darge
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)
22 views69 pages

BCS Chapter 3

lecture

Uploaded by

Getu Darge
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/ 69

Chapter 3: Data representation and

computer arithmetic
• Data representation in computers (Bit, Byte,
Word)
• Number System ( Binary, Octal, and
Hexadecimal number system)
• Conversion from one number system to another
• Computer arithmetic (Representation of
negative number and decimal number)
• Coding methods (EBCDIC BCD ASCII, UNICODE)

07/02/2024 By Metekia S. 1
Bit Byte word cont…
• computer’s net intelligence is absolutely zero i.e.
computer is not capable of understanding anything except
zeros and ones.
• In computer every instruction is interpreted and executed
in the form of binary system.
• It is a state of “on” or “off” in a digital circuit.
• Sometimes they represent high or low voltage Fully
Charged - Fully Discharged
– Magnetized – Demagnetized
• Programs are written in HLL which then will be converted
to ML (0,1)
07/02/2024 By Metekia S. 2
Bits, Bytes, word ..
• A computer’s internal storage techniques are different
from the way people represent information in daily lives
– We see and type numbers and letters.
– The computer sees ones and zeros for everything
• All information inside a digital computer is stored as a
collection of binary data
• A bit is one or zero (0 or 1)
– Short for “binary digit”
– Group of continuous 4 bits is termed as Nibble

07/02/2024 By Metekia S. 3
Bit Byte word cont…
• A byte is a collection of 8 bits
– One character (letter ) = one byte
• A word is a fixed-sized group of bits that are handled together
by the machine.
– A Word usually consists of 32 bits, which is equal to 4
bytes
• 1 KILO = 1024 bytes (approx. 103 bytes)
• 1 MEGA = 103 K B
• 1 GIGA = 103 M B
• 1 TERA = 103 G B
• 1 PETA = 103 TERA B
07/02/2024 By Metekia S. 4
Number system
• Why binary ? Because its easier to make hardware which can
distinguish between two values than multiple values
– More reliable …
• Binary numbering system
– Base-2
– Built from ones and zeros
– Each position is a power of 2
1101 = 1 x 23 + 1 x 22 + 0 x 21 + 1 x 20
• Decimal numbering system
– Base-10
– Each position is a power of 10
3052 = 3 x 103 + 0 x 102 + 5 x 101 + 2 x 100
07/02/2024 By Metekia S. 5
Positional number notation vs Non-
Positional number systems
• Non-Positional number systems: - is a method
of counting on fingers such as I for 1, II for 2, III
for 3, IIII for 4 etc.
• It was very difficult to perform arithmetic with
such a number system, as it had no symbol for
zero.

07/02/2024 By Metekia S. 6
Positional number notation vs
Non-Positional number systems
• the value of each digit in a number is defined not
only by the symbol but also by the symbol’s position.
• They have a base or radix(number of digits available )
– 1012 = 1×22 + 0×21 + 1×20 = 510
– 63.48 = 6×81 + 3×80 + 4×8–1 = 51.510
– A116 = 10×161 + 1×160 = 16110

07/02/2024 By Metekia S. 7
The Binary Numbering System (0-15)

07/02/2024 By Metekia S. 8
Conversion Among Bases
• The possibilities:

Decimal Octal

Binary Hexadecimal

07/02/2024 By Metekia S. 9
Binary to Decimal
• Technique
– Multiply each bit by 2n, where n is the “weight” of
the bit
– The weight is the position of the bit, starting from
0 on the right
101011 => 1 x 2 = 1
– Add the results
0
2
1 x 21
= 2
0 x 22
= 0
1 x 23
= 8
0 x 24
07/02/2024
=
By Metekia S.
0 10
1 x 25
Octal to Decimal
• Technique
– Multiply each bit by 8n, where n is the “weight” of
the bit
– The weight is the position of the bit, starting from
0 on the right
– Add the results

07/02/2024 By Metekia S. 11
Example

7248 => 4 x 80 = 4
2 x 81 = 16
7 x 82 = 448
46810

07/02/2024 By Metekia S. 12
Hexadecimal to Decimal

Decimal Octal

Binary Hexadecimal

07/02/2024 By Metekia S. 13
Hexadecimal to Decimal
• Technique
– Multiply each bit by 16n, where n is the “weight”
of the bit
– The weight is the position of the bit, starting from
0 on the right
– Add the results

07/02/2024 By Metekia S. 14
Example

ABC16 => C x 160 = 12 x 1 = 12


B x 161 = 11 x 16 = 176
A x 162 = 10 x 256 = 2560
274810

07/02/2024 By Metekia S. 15
Decimal to Binary

Decimal Octal

Binary Hexadecimal

07/02/2024 By Metekia S. 16
Decimal to Binary
• Technique
– Divide by two, keep track of the remainder
– First remainder is bit 0 (LSB, least-significant bit)
– Second remainder is bit 1
– Etc.

07/02/2024 By Metekia S. 17
07/02/2024 By Metekia S. 18
Octal to Binary

Decimal Octal

Binary Hexadecimal

07/02/2024 By Metekia S. 19
Octal to Binary
• Technique
– Convert each octal digit to a 3-bit equivalent
binary representation

07/02/2024 By Metekia S. 20
Example
7058 = ?2

7 0 5

111 000 101

7058 = 1110001012

07/02/2024 By Metekia S. 21
Hexadecimal to Binary

Decimal Octal

Binary Hexadecimal

07/02/2024 By Metekia S. 22
Hexadecimal to Binary
• Technique
– Convert each hexadecimal digit to a 4-bit
equivalent binary representation

07/02/2024 By Metekia S. 23
Example
10AF16 = ?2

1 0 A F

0001 0000 1010 1111

10AF16 = 00010000101011112

07/02/2024 By Metekia S. 24
Decimal to Octal

Decimal Octal

Binary Hexadecimal

07/02/2024 By Metekia S. 25
Decimal to Octal
• Technique
– Divide by 8
– Keep track of the remainder

07/02/2024 By Metekia S. 26
07/02/2024 By Metekia S. 27
Decimal to Hexadecimal

Decimal Octal

Binary Hexadecimal

07/02/2024 By Metekia S. 28
Decimal to Hexadecimal
• Technique
– Divide by 16
– Keep track of the remainder

07/02/2024 By Metekia S. 29
07/02/2024 By Metekia S. 30
Binary to Octal

Decimal Octal

Binary Hexadecimal

07/02/2024 By Metekia S. 31
Binary to Octal
• Technique
– Group bits in threes, starting on right
– Convert to octal digits

07/02/2024 By Metekia S. 32
Example
10110101112 = ?8

1 011 010 111

1 3 2 7

10110101112 = 13278

07/02/2024 By Metekia S. 33
Binary to Hexadecimal

Decimal Octal

Binary Hexadecimal

07/02/2024 By Metekia S. 34
Binary to Hexadecimal
• Technique
– Group bits in fours, starting on right
– Convert to hexadecimal digits

07/02/2024 By Metekia S. 35
Example
10101110112 = ?16

10 1011 1011

2 B B

10101110112 = 2BB16

07/02/2024 By Metekia S. 36
Exercise – Convert ...
Hexa-
Decimal Binary Octal decimal
33
1110101
703
1AF

Don’t use a calculator!

Skip answer Answer

07/02/2024 By Metekia S. 37
Exercise –Answer
Convert …
Hexa-
Decimal Binary Octal decimal
33 100001 41 21
117 1110101 165 75
451 111000011 703 1C3
431 110101111 657 1AF

07/02/2024 By Metekia S. 38
Fractions
• Binary to decimal
10.1011 => 1 x 2-4 = 0.0625
1 x 2-3 = 0.125
0 x 2-2 = 0.0
1 x 2-1 = 0.5
0 x 20 = 0.0
1 x 21 = 2.0
2.6875

pp. 46-50

07/02/2024 By Metekia S. 39
Fractions
• Decimal to binary (0.68 )

pp. 46-50

07/02/2024 By Metekia S. 40
Fraction
• In some circumstances of changing the
decimal fraction may not end. In such cases
you have to take the approximate of 8 bits.

07/02/2024 By Metekia S. 41
Fractions
• Decimal to binary:
.14579
x 2
3.14579 0.29158
x 2
0.58316
x 2
1.16632
x 2
0.33264
x 2
0.66528
x 2
1.33056
11.001001... etc.

p. 50

07/02/2024 By Metekia S. 42
Fraction
• Decimal to oclal
• Example: Determine the octal equivalent of
(0.3125) 10.
0.3125 x 8 = 2.5 2
0.5 x 8 = 4.0 4

So, (0.3125) 10 = (0.24) 8

07/02/2024 By Metekia S. 43
Fraction
• Decimal to hexadecimal

07/02/2024 By Metekia S. 44
Exercise – Convert ...
Hexa-
Decimal Binary Octal decimal
29.8
101.1101
3.07
C.82
Don’t use a calculator!

Skip answer Answer

07/02/2024 By Metekia S. 45
Exercise –Answer
Convert …
Hexa-
Decimal Binary Octal decimal
29.8 11101.110011… 35.63… 1D.CC…
5.8125 101.1101 5.64 5.D
3.109375 11.000111 3.07 3.1C
12.5078125 1100.10000010 14.404 C.82

07/02/2024 By Metekia S. 46
Common Powers (1 of 2)
• Base 10 Power Preface Symbol Value
10-12 pico p .000000000001

10-9 nano n .000000001

10-6 micro  .000001

10-3 milli m .001

103 kilo k 1000

106 mega M 1000000

109 giga G 1000000000


1012 tera T 1000000000000

07/02/2024 By Metekia S. 47
Common Powers (2 of 2)
• Base 2 Power Preface Symbol Value
210 kilo k 1024

220 mega M 1048576

230 Giga G 1073741824

• What is the value of “k”, “M”, and “G”?

07/02/2024 By Metekia S. 48
Example
In the lab…
1. Double click on My Computer
2. Right click on C:
3. Click on Properties

/ 230 =

07/02/2024 By Metekia S. 49
Binary Addition

• Two n-bit values


– Add individual bits
– Propagate carries
– E.g., In binary 1+1 = 10 (which is 2)
1 1
10101 21
+ 11001 + 25
101110 46

07/02/2024 By Metekia S. 50
Binary subtraction

07/02/2024 By Metekia S. 51
Octal Addition
• During the process of addition, if the sum is less than
or equal to 7, then it can be directly written as octal
digit.
• If the sum is greater than 7, then subtract 8 from that
particular digit and carry 1 to the next digit position.

07/02/2024 By Metekia S. 52
Octal Subtraction
• we will borrow 8 and the rest of steps are similar to
that of binary subtraction.

07/02/2024 By Metekia S. 53
Hexadecimal addition
• During the process of addition, observe if the sum is 15 or
less, then it can be directly expressed as hexadecimal digit.
• If the sum is greater than 15, then subtract 16 from that
particular digit and carry 1 to the next digit position.

07/02/2024 By Metekia S. 54
Hexadecimal subtraction
• 16 will be used as borrow

07/02/2024 By Metekia S. 55
Multiplication
• Binary, two 1-bit values

A B A B
0 0 0
0 1 0
1 0 0
1 1 1

07/02/2024 By Metekia S. 56
Multiplication (3 of 3)
• Binary, two n-bit values
– As with decimal values
– E.g.,
1110
x 1011
1110
1110
0000
1110
10011010

07/02/2024 By Metekia S. 57
Coding methods (EBCDIC BCD ASCII,
UNICODE)
• Computer system encodes the data by means
of binary or digital coding schemes to
represent letters, numbers and special
characters (@ ,%, $).
• Some of the commonly used schemes are
EBCDIC, ASCII, and Unicode.

07/02/2024 By Metekia S. 58
BCD 6 bit

07/02/2024 By Metekia S. 59
Coding methods (EBCDIC BCD ASCII,
UNICODE)
• BCD is one of the early memory codes. In BCD each digit
of a decimal number is converted into its binary
equivalent
• and each decimal digit uses 4 bits for this conversion.
• BCD started using 6 bit since 4 bit was not enough to
represent all the characters
• Example: 4210 is not equal to 1010102 in BCD
4210 is equal to 0100 00102 in BCD
1010 = 0001 0000 in BCD
1510 = 0001 0101 in BCD
07/02/2024 By Metekia S. 60
EBCDIC

07/02/2024 By Metekia S. 61
Example

07/02/2024 By Metekia S. 62
ASCII (American Standard Code for
Information Interchange)
• it is the built-in binary code for representing
characters in all computers except IBM
mainframes, which use the EBCDIC coding
system.
• ASCII is the binary code used in most of the
microcomputers.
• ASCII-7 uses 7 bit
• ASCII-8 uses 8 bit

07/02/2024 By Metekia S. 63
ASCII Code
Code Char Code Char Code Char Code Char
32 Space 48 0 65 A 97 a
33 ! 49 1 66 B 98 b
34 " 50 2 67 C 99 c
35 # 51 3 68 D 100 d
36 $ 52 4 69 E 101 e

By Metekia S.
37 % 53 5 70 F 102 f
38 & 54 6 71 G 103 g
39 ' 55 7 72 H 104 h
40 ( 56 8 73 I 105 i
41 ) 57 9 74 J 106 j
… … … … … … … …

07/02/2024 64
UNI CODE
• UNI code is an international standard that provides a single
encoding for all the world’s languages.
• By adding support for Unicode, applications can create
process and display information in any language. (amharic)
• UNI code uses two byte or 16 bit
• 65,536 character combination
• ISCII Code
• It is Indian Standard Code for Information Interchange
code. It is 8-bit code, which is developed to represent the
Indian script alphabets.

07/02/2024 By Metekia S. 65
Signed numbers
• How to Represent Negative Numbers on
Computers?
• Using,
• Sign And Magnitude Method
• One’s Complement Method
• Two’s Complement Method

07/02/2024 By Metekia S. 66
07/02/2024 By Metekia S. 67
07/02/2024 By Metekia S. 68
2.5 Floating-Point Representation

• Computers use a form of scientific notation for


floating-point representation
• Numbers written in scientific notation have three
components:

121.5 = 1.125 *102


101010.111= 1.01010 * 25
07/02/2024 By Metekia S. 69

You might also like