Learning Unit 1 - Data Representation
Learning Unit 1 - Data Representation
R E P R E S E N TAT I O N A N D S T O R A G E
Binary,
C R E AT EDecimal,
D B Y A I DHexadecimal,
AN BANKS Octal
INTRODUCTION
01011100
010101010000101010
HEXADECIMAL EXAMPLES:
Hexadecimal (base-16) is used in
many computer contexts. This uses
numbers and letters. A113 DID0
76
ACE
DF
CONVERSIONS
CONVERT BINARY TO DECIMAL
CONVERT DECIMAL TO BINARY
CONVERT DECIMAL TO HEXADECIMAL
CONVERT HEXADECIMAL TO DECIMAL
CONVERT HEXADECIMAL TO BINARY
CONVERT BINARY TO HEXADECIMAL
N U M B E R O F C O M B I N AT I O N S F O R
NUMBER OF BITS
Word size generally increases as
WORD SIZE processors become more
powerful For example, current
The word size, also known as
word size is 32 or 64 bits. The
word length, is the number of
number of bits in a word has many
bits that a computer, more
applications, one being the
precisely the processer, can work
number of possible combinations
with at one time. It is too
that can be stored in a fix number
inefficient to work with individual
of bits
bits, so bits are grouped
n
together into units called words, This can be calculated by
2
just like letters are grouped into using the formula:
words
D ATA S T O R A G E
The size of memory capacity such as RAM and Hard Disk Drives is measured
10
in multiple of bytes. A kilobyte (1KB) is 2 bytes which is 1024 bytes and not
100 bytes.
8 Bits = 1 Byte
In 8 bits, where all the bits are allocated to storing the number, the largest
number that can be represented is shown in the table below. Since the table
represents how the number is represented in a computer, it is not necessary
to write base 2.
1 1 1 1 1 1 1 1
n
Formula:
2 −1 The n is the number of bits.
UNSIGNED INTEGERS
SMALLEST NUMBER IN AN UNSIGNED INTEGER
The smallest unsigned number is 0. Since we do not have a bit to store the
sign, we can only store positive numbers
0 0 0 0 0 0 0 0
SIGNED INTEGERS
LARGEST NUMBER IN AN UNSIGNED INTEGER
To store numbers, we allocate the first bit to the sign leaving one less bit to
store the number. If the first bug is 0, the number is positive and if it is 1, the
number is negative. The large value that can be stored is 8 bits is.
0 1 1 1 1 1 1 1
n−1
Formula:
2 −1 The n is the number of bits.
SIGNED INTEGERS
SMALLEST NUMBER IN AN UNSIGNED INTEGER
We do not need to subtract one from the total as we did for the positive
since 0 has been accounted for in the positive integers.
n−1
Formula:
−2
P R I M I T I V E D ATA T Y P E S
Most programming languages provide basic data types to store characters,
text (String), real numbers and integers.
D I G I TA L C H A R A C T E R
R E P R E S E N TAT I O N
ASCII
The first widely used character set was
ASCII where each character was
represented in 8 bits and contained the
alphabetic characters (A -Z and a - z),
numbered characters (0-9, 1/2, 1/4),
some codes are accented, some Greek
letters, icons and limited number of lin
draw symbols which gave the screen very
limited graphical capabilities. It was
extended to 256 characters.
UNICODE AND UTF-8
Unicode
It provides a standard that provides a unique code number fro every
character, no matter what OS, device, application or language.
UNICODE AND UTF-8
UTF-8
Every character is represented by at least 8 bits per character (1 byte).
S T O R I N G S C R E E N D ATA
REPRESENTING COLOUR
Pixels are tiny dots on the screen. Each
pixel has its own colour definition. Colour
can be defined either RGB or other colour
definition.
RGB (Red Green Blue) is a system of producing
any colour light by adding varying intensities of
red, green and blue. Each colour is represented
by a byte. Echo byte has 256 combinations and
numbering from 9 to 255.
FOR BLACK:
Bytes 0 0 0
Bits 0 0 0
Hex 0 0 0
FOR WHITE:
Hex FF FF FF
EACH COLOUR CAN BE ONE
OF 256 (RED) X 256 (GREEN) X
2 5 6 ( B L U E ) VA L U E S
PRODUCING 16,77,216
POSSIBLE COLOURS.
Current resolutions range from 360 x 640 to 1920 x 1080. If we use 360 x 640
pixels and 3 bytes for each pixel each screen will need: