UNIT 2: Data
2.1: Binary
❖ Transistors: Tiny electronic components combined in circuits and etched onto silicon chips. A single transistor
has 2 states: high [on] and low [off].
❖ In binary these two states are represented as 1 [for on] and 0 [for off].
➢ These are called binary digits [bits].
➢ All data is represented as a pattern of bits in a computer system.
❖ The number of binary patterns that can be produced by a group of n bits is expressed as
Using binary to represent data and program instructions
❖ Font Definition: Define how a font is to be displayed on a screen.
❖ When a computer is asked to display a binary pattern as characters on the screen, it looks up the graphical
representation for it in a font definition and sends it to the screen hardware.
❖ To encode an image, each tiny picture element [pixel] is allocated its own binary pattern.
❖ All encoding systems are limited by the number of available bits.
➢ With 4 bits [a nibble], 16 colours can be assigned a unique binary pattern.
➢ With 24 bits [3 bytes], more than 16 million colours can be represented.
➢ The more bits that are used in an encoding system, the more distinct values can be represented in binary,
but the more space is required to store the binary code.
Number Systems
❖ Signed Numbers: Numbers that can be either positive or negative, indicated by its sign.
❖ Unsigned Numbers: Numbers with a non-negative value of 0 or more.
❖ A 1 byte [8 bit] unsigned integer has a range of 0 to 255, whilst a 1 byte signed integer has range of -128 to +127.
➢ Both have 256 different values, but signed numbers use ½ their range for negative values whilst unsigned
numbers have positive values that are twice as large.
➢ This is because the first column of a signed 8 bit integer will be worth -128 instead of 128.
❖ Denary system works in powers of 10, whereas the binary system uses powers of 2.
Binary System
❖ In the binary system, place values increase by powers of 2.
❖ MSB: The bit in the leftmost position. It has the highest place value.
➢ The place value of the MSB of a binary number of length n is .
❖ LSB: The bit in the rightmost position. It has the lowest place value.
➢ The place value of the LSB is always .
, ❖ There are 256 different binary patterns generated by an 8-bit binary number, meaning that it can be used to
represent positive denary integers in the range 0-255.
[2.1.3] Converting positive denary numbers to binary
[2.1.2]Two’s Complement
❖ Two's complement is used to show positive and negative
numbers.
➢ The MSB has been designed to act as the sign bit
[An MSB of 1 makes the number negative].
➢ Range: -128 [1000 0000] => +127 [0111 1111].
,[2.1.5] Overflow
❖ When a computer performs a binary arithmetic, it sets aside a predetermined amount of storage to hold the result.
An overflow occurs when an operation produces a result that requires more bits to store it than are available in the
computer.
❖ Any time an operation produces an inaccurate result, program errors may occur, and the programs may crash or
produce unreliable/incorrect results.
[2.1.6] Hexadecimal
❖ Hexadecimal: A number system designed to help humans handle large binary numbers.
❖ Some uses of hexadecimal:
➢ It helps humans cope with long strings of binary digits.
➢ When a computer malfunctions, error codes are usually given in hexadecimal.
➢ It is used to represent numerical values in assembly language.
➢ True colour uses 24 bits to code every available colour variation [224 ] – each of the three 8-bit numbers
which represent each colour can be simplified to three 2-digit hexadecimal ones [e.g. 1100 0110 0011
0000 1111 0100 => C6230F4].
❖ The # symbol is used to denote a hexadecimal number.
❖ The system uses 16 values: 0-15.
❖ Each nibble can be represented as one hexadecimal digit.
❖ Since denary only has digits for 0-9, hexadecimal digits larger than 9 [10-15] are represented by uppercase A-F.
, 2.2: Data Representation
[2.2.1] ASCII
❖ Character set: The list of binary codes that can be recognised by a computer’s hardware and software.
❖ ASCII: American Standard Code for Information Interchange: A 7-bit binary code [128 (27 )sequences] used to
represent text, with each character assigned a value
between 0 and 127.
➢ 0 = 48
➢ 9 = 57
➢ A = 65
➢ Z = 90
➢ a = 97
❖ Relational operator: An operator that compares two
values [for example ‘B’ > ‘D’].
❖ ASCII only has enough values to represent English letters [along with some other characters] and control actions].
➢ In order to represent other languages/alphabets, more bits are needed – so an 8-bit version [Extended
ASCII] tried to overcome this problem, but even using 256 binary patterns doesn’t let it support a large
enough character set.
❖ Unicode was introduced.
➢ Unicode uses more bits to store more characters [32].
[2.2.2] Representation of bitmap images
❖ Bitmap: A digital image composed of tiny blocks of colour called pixels.
❖ Pixels: Short for ‘picture element’, it is the smallest element of a bitmap image. If an image size remains constant,
then the more pixels there are, the sharper and more detailed the image is.
❖ Resolution: This determines the size of an image when it is displayed on-screen or printed on paper.
➢ It is measured in pixels per inch [PPI].
➢ When a small image is enlarged to cover a larger area, resolution decreases and the image becomes less
sharp. There are now fewer pixels for a fixed area.
➢ If an image is enlarged too much, it becomes pixelated.
➢ Pixelated: An image in which the individual pixels are visible.