0% found this document useful (0 votes)
51 views25 pages

L2 - Bits, Bytes and Digital Information

Uploaded by

azzehhamzeh360
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)
51 views25 pages

L2 - Bits, Bytes and Digital Information

Uploaded by

azzehhamzeh360
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/ 25

Bits, bytes and

digital information
Today’s
lecture
 Understand the difference between
analogue and digital information
 Convert between decimal numbers and
binary numbers.
 Convert between Decimal and Octal
numbers
 Convert between Decimal and Hexa-
decimal Numbers
Analogue vs digital
information
 Information in the real world is
continuous
 Continuous signal

Weigh
t
shown

R
e
a
l

W
e
iReal Weight
g
h
Encoding
information
 Real world information is stored by a
computer using numbers

 Visual information
11111111111111111111111
01111111111111111111111
00001111111111111111111
00000011111111111111111
00000000011111111111111
44444000001111111111111
75444000000011111111111
55554401000000111111111
33367544000000011111111
22283554444000000111111
99928357544000000011111
99999233657504000001111
99999983666554400000011
99999928338674400000001

Image Pixels
1. Give each pixel colour a number.
2. Let the computer draw the numbers as
coloured pixels (eg. black = 0).
Encoding
information
 Sound
information

Sound

Wavefor Samples
m
1. Give each sample a number (height of
green box).
2. Let the computer move the
loudspeaker membrane according to
the samples.
Numbers and
Computing
 Numbers are used to represent all
information manipulated by a computer.

 Computers use the binary number


system:
— Binary values are either 0 or 1.

 We use the decimal number system:


— 0 to 9 are decimal values.
Number
Systems
 Base:
— Specifies the number of digits used by the
system.
— Binary is base 2.
— Decimal is base 10.

 Positional notation:
— Describes how numbers are written.

Most significant 𝑑𝑑𝑛𝑛 𝑑𝑑𝑛𝑛 −1 ⋯ 𝑑𝑑Least


1 significant
digit digit
Positional
Notation
 Any number can be expressed as:

𝑑𝑑𝑛 ∗ 𝑏𝑏𝑛𝑛 −1 + 𝑑𝑑𝑛 −1 ∗ 𝑏𝑏𝑛𝑛 −2 + ⋯


+ 𝑑𝑑1 ∗ 𝑏𝑏0

wher 𝑑𝑑𝑖𝑖 is the digit at position 𝑖𝑖, and 𝑏𝑏


e is the
base.
Decimal
Examples
6 ∗ 102 + 5 ∗ 101 + 7
 657

∗ 100

600 + 50 + 7 = 657

9 ∗ 103 + 3 ∗ 102 + 0 ∗ 101 + 8


 9308

∗ 100

9000 + 300 + 0 + 8 = 9308


Storing Decimal Numbers in a
Computer
 Series of dials:
— Each dial goes from 0 to 9.

 Information is stored digitally:


— Finite number of states – 10 per
dial.
— No in-between states.
 Decimal number
system:
1st dial from right: 100
6 ∗ 102 + 3 ∗ 101 + 8 ∗ 100 =
2nd dial from right: 101

638
3rd dial from right: 102


— etc.
Exercis
esfollowing two questions relate to dials
The
that have 10 different states, as
discussed in the previous slide.

 Given a machine that uses 4 dials, how


many different numbers can we
represent?

 Ifwe want to represent 256 different


values, how many dials do we need?
Switch
es
 A dial is complicated.
— Each dial has 10 different states (0 – 9).
— Physically creating circuits that distinguish all
states is complicated.
— Would need to distinguish 10 different
strengths of electricity (voltages).

 Switches are simple.


— Each switch is off or on (0 or 1).
— Physically creating the circuits is easy.
— Switch off: electrical current cannot flow.
— Switch on: electrical current can flow.
Bits and
Bytes
 Each binary number is known as a Binary
digIT, or bit.

 A bit can be either a 0 or a 1

 Bits are used in


groups.

A group of eight bits is referred to as a


byte.
Using Binary
Numbers
How many different values/states can we
have with:
1 bit: 2 bits: 3 bits:

00 10
0
000 0

1 01 10
001 11
0
10 11
010 1
Exercis
es
 How many different values can we
represent with a byte?

 Ifwe want to represent 30 different values,


how many bits would we need?
Converting binary to
decimal
1 ∗ 22 + 1 ∗ 21 + 0
 110

∗ 20

4+2+0=6

1 ∗ 24 + 0 ∗ 23 + 1 ∗ 22 + 1 ∗ 21 +
 10110

0 ∗ 20

16 + 0 + 4 + 2 + 0 = 22
Converting from decimal to
binary
 35  106
2 106
2 35
2 53 0
2 17 1
2 26 1
2 8 1
Read the 2 13 0
2 4 0 Read the
remainders from 2 6 1 remainders from
2 2 0 the bottom up. 2 3 0 the bottom up.
2 1 0
2 1 1
0 1
0 1

 35 is 100011 in  106 is 1101010 in


binary binary
Exercis
es
 What is the decimal equivalent of
101111?

What is the binary equivalent of


123?
Prefix
es
 A group of 8 bits is a byte
A group of 4 bits is a nibble

 Bytes are the common unit of


measurement for memory capacity

 There are two sets of prefixes:


 Decimal
 Binary
Decimal
prefixes
10n

1
Prefix

none
Symbol Decimal

103 kilo K 1000

106 mega M 1,000,000

109 giga G 1,000,000,000

1012 tera T 1,000,000,000,000

1015 peta P 1,000,000,000,000,000

1018 exa E 1,000,000,000,000,000,000

1021 zetta Z 1,000,000,000,000,000,000,000


Binary
prefixes
2n Prefix Symbol Decimal

20 none 1

210 kibi Ki 1024

220 mebi Mi 1,048,576

230 gibi Gi 1,073,741,824

240 tebi Ti 1,099,511,627,776

250 pebi Pi 1,125,899,906,842,624

260 exbi Ei 1,152,921,504,606,846,976

270 zebi Zi 1,180,591,620,717,411,303,424


Prefixes in Computer
Science
 Both decimal and binary prefixes are
used in Computer Science

 Decimal prefixes are preferred because they


are easier to calculate, however binary
prefixes are more accurate
Binary prefix Decimal prefix Value (bytes)

8 bits 1 byte same

1 KiB 1 KB 1024 ≠ 1000


(1 x 2 bytes)
10 (1 x 103 bytes)

1 MiB 1 MB 1,048,576 ≠ 1,000,000


(1 x 220 bytes) (1 x 106 bytes)
Example – hard disk
sizes
 A 160GB hard disk is equivalent to
149.01GiB
 160GB = 160 x 109
 149.01GiB = (160 x 109) ÷ 230
Exercis
es
 Which has more bytes, 1KB or
1KiB?

How many bytes are in


128MB?
Summa
ry
 Computers use the binary number system
 We can convert numbers between decimal and
binary

 Decimalprefixes and binary prefixes are


used for counting large numbers of
bytes

You might also like