Number Systems
Number Systems
RubyBart
Lessons
1. How are numbers, text and images
represented inside the computer system?
2. Discussing the 2 state computer system
3. Converting positive whole numbers to binary
and vice versa
4. Playing Binary Bingo
Data Representation
34
128 64 32 16 8 4 2 1
0 0 1 0 0 0 1 0
= 32 + 2
134
128 64 32 16 8 4 2 1
1 0 0 0 0 1 1 0
= 128 + 4 + 2
Binary back to Decimal
1011 0011
128 64 32 16 8 4 2 1
1 0 1 1 0 0 1 1
= 128 + 32 + 16 + 2 + 1
=179
Binary to Decimal
1. What is the decimal 2. What is the 8 bit
representation of the representation of the
following 8 bits using following decimal
2s complement numbers
(a) 0001 0110 (a) 174
(b) 1000 1100 (b) 121
(c) 0111 0011 (c) 71
Binary Bingo
42 13
81 209
21 32
16 56
121 175
73 192
101 186
75 176
127 121
Data Storage
1 or 0 = 1 bit
8 bits = 1 byte
1024 bytes = 1 kilobyte
1024 kilobytes = 1 megabyte
1024 megabytes = 1 gigabyte
Aims of Lesson 2
1. Representation of negative whole numbers
2. The 2s complement system
Representing Negative
Numbers
The signed bit method
0000 0001 = 1
0000 0000 = 0
1000 0001 = -1
1000 0010 = -2
1000 0011 = -3
1000 0100 = -4
Representing Negative
Numbers
There is a problem with this method??
Using 8 bits you can only store the decimal
numbers from
128 64 32 16 8 4 2 1
1 1 1 1 1 1 1 1
= 64 +32+16+8+4+2+1 = -127
128 64 32 16 8 4 2 1
0 1 1 1 1 1 1 1
=64+32+16+8+4+2+1=127
Rather than -255 to 255
2s Complement
What is the 8 bit two’s complement representation of
the decimal number -101
101
128 64 32 16 8 4 2 1
0 1 1 0 0 1 0 1
Invert numbers
1 0 0 1 1 0 1 0
+1
-101
1 0 0 1 1 0 1 1
Negative Whole Numbers
What is the decimal representation of the
following 8 bits using 2s complement
1 0 1 0 1 1 1 1
You invert every number
0 1 0 1 0 0 0 0
Then add 1
0 1 0 1 0 0 0 1
128 64 32 16 8 4 2 1
64+16+1
-81
2s Complement Questions
1. What is the decimal 2. What is the 8 bit two’s
representation of the complement
following 8 bits using representation of the
2s complement following decimal
(a) 1000 1011 numbers
(b) 1100 1100 (a) -45
(c) 1001 0111 (b) -121
(d) 1110 1100 (c) -176
(d) -71
Aims of Lesson 3
1. So far we have looked at representing
positive and negative whole numbers using
binary
2. We are now going to look at the
representation of non whole numbers using
the floating point system
Representing Non Whole
Numbers
How do we represent the number 128.75 in
binary?
1 0 0 0 0 0 0 0 1 1 0 0
1 0 0 0 0 0 0 0 1 1 0 0
Mantissa
1 0 0 0 0 0 0 0 1 1 0 0
Exponent
8
8 4 2 1
1 0 0 0
How do we represent the number 38.125 using
floating point
32 16 8 4 2 1 0.5 0.25 0.125 0.0625
1 0 0 1 1 0 0 0 1 0
Mantissa
1 0 0 1 1 0 0 0 1 0
Exponent
6
8 4 2 1
0 1 1 0
Representing Non Whole
Numbers
Mantissa relates to the precision of the
number you can represent i.e 34.44454321
8 4 2 1 0.5 0.25 0.125 0.075 0.0375 0.01875 0.009375
1 0 0 1 0 0 1 1
8 bits = 1 byte
PIXEL
MEMORY REQUIRED
Bit Map = the graphic is made up
from a series of pixels 8 BITS X 8 BITS = 64 BITS
= 8 BYTES
Graphics Resolution
The smaller the size of
the pixels, the finer the
detail of the image
800 x 600 pixels lower
quality than 1024 x 768 Pixel Pattern Pixel Pattern
using 8x8 grid using 16x16 grid
As the number of pixels
increases so does the
storage space required
Calculating Storage Capacities
of Bit Mapped Images
Storage Requirements = total number of pixels * number of
bits used for each pixel
This picture of Mr Haggarty has a resolution of 300dpi. The
image is 2 inches by 4 inches in 128 colours
300 X 2 = width 600 pixels
300 X 4 = height 1200 pixels
Total pixels = 600 X 1200 = 720,000 pixels
Each pixel = 7 bits i.e. 27= 128 colours
720,000 X 7 = 5,040,000 bits / 8 = 630,000 bytes
630,000 / 1024 = 615Kb
Bit Map V Vector Graphics
Bit Map Graphic Vector Graphic
Bit map packages paint Work by drawing objects on
pictures by changing the the screen
colour of the pixels Known as “Draw Packages”
Known as “Paint Packages” When shapes overlap they
When shapes overlap, the remain as separate objects
one on top rubs out the Only the object attributes
other are stored taking up much
When you save a file the less space
whole screen is saved Resolution Independent
The resolution of the image
is fixed when you create the
image
Aims of Lesson 6
Last Lessons Today’s Lesson
Representing positive whole 1. Discuss true colour
numbers as binary
Representing negative
whole numbers using 2s Today’s Tasks
complement
Non whole numbers using 1. Complete Data
mantissa and exponent Representation Questions
Storage calculations 2. Read chapter in the book
Looked at how text is
represented using ASCII
and Unicode
Discuss graphic
representation
Calculate storage capacities
of colour Bit Map graphics
Bit Map v Vector
Bit Depth = 1 bit
True Colour
Bit Depth (Colour Depth)
The number of bits used to represent colours in the
graphic
1 bit = black or white
2 bits = 4 colours Bit Depth = 2 bit
3 bits = 8 colours
8 bits = 256 colours
24 bits = 16,777,216 colours this is true colour
True Colour
24 bits
Human eye cannot
8 bits for red
distinguish between
8 bits for blue
adjacent shades of
8 bits for green grey when looking at
more than 200
shades between
black and white
Bit Depth = 2 bits
Bit Depths 01
11
10
00
Solutions
Question 1 Question 2
2 inches X 90 = 180 pixels 5 inches X 200 = 1000
2 inches X 90 = 180 pixels pixels
180 X 180 = 32,400 pixels 3 inches X 200 = 600 pixels
in total 1000 X 600 = 600,000
256 colours = 2 power 8 pixels in total
32,400 X 8 = 259,200 bits 128 colours = 2 power 7