0 ratings0% found this document useful (0 votes) 52 views36 pagesZNote For Theory
AQA A-Level Computer Science Theory Note
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
AQAA LEVEL
Prepared for Adenekan fer persnal Use orces er
1, Data Representation
1.1. Number Systems
+ Natural Numbers: base 10 numbers used for everyday
counting, Postve integers for Dto=
* Uses: counter n processor, identi location of data
ina structure, score variables, counting
N= (0,1,2,34...)
+ Integer Numbers: whole numbers (no fractional part)
that can be posite or negative
Z=(...-3,-%—1)0)1,2,3,4...)
+ Rational Numbers: canbe expressed fractionally, as
quotients). Quotient can equal 1 (5/5=1 soll integers
are rational
+ Denominator cannot be 0
Q = (1/3,1/2,3/4...)
+ rational Numbers values after decimal place do not
repeat. Cannot be represented as 2 ratio between two
integers.
"Programmer needs to decide how many decimal
places to use
+ Egv2orm
+ Real Numbers: any postve or negative number, with or
withouta factional part. Fractional part canbe any
length, allowing any level of precsion/accuraty
+ Refines possible reaorld quantities
+ Usesi measurements, CNC, time, robotics, data
control systems
+ Ordinal Numbers: number used to identily postion
telatve to other numbers
+ Cardinal Numbers: a number that defines the sizeof
something
+ Well Ordered Set: group of related numbers with 8
defined order
1.2. Number Bases
“Number base! defines how many digits are used to
represent a number.
+ Decimal: uses 10 digi (0 + ) and increases by powers
of 10
‘Uses: humans for counting
+ Base 10:
+ Binary: uses 2 digs (0 and 1)
‘+ Uses: computers, because electronic gates can only
be open or closed
+ Base2:#
+ Hexadecimal: used 16 digits (0+ F)
‘+ Why: shorthand for binary, as 2 hex digits can
represent a byte. Requires less digits than binary,
takes up less screen space, easier for humans to
Understand than binary strings
‘Uses: HTML hex colour codes, MAC addresses,
‘memory dumps, error messages
Base 16: ft.
+ Binary -> Decimal using binary columns, add up all
values that have a1 underneath.
+ Decimal —- Binary using binary columns, see if value will
fit under most significant colurnn, then repeat with
remainder and next colurnn. Or, start with the least
significant column and divide by 2 each time. If
remainder is 0, then 0 is placed inthe column.
+ Decimal -> Hex convert to binary, split into nibbles, then
tur each nibble into hex, and push values together.
‘+ Hex — Decimal take each hex value, turnit into binary,
then push the nibbles of binary together. Turn binary
into decimal
1.3. Units of Information
+ Bit: the fundamental unit of information, that is either 0
ort
+ Oisoff, and 1 is on
inary Digit
+ Byte: a group of 8 bits
‘+ 2n values represented with n bits: where nis the
umber of bits used, 2n is the number of possible
‘combinations
‘+ Eg. 2°=B, so with 3 bts, there are 8 combinations
‘Units: binary increments in 102, Decimal units
Increment in 1000
‘+ Inthe past, kilobyte has been used to mean kiblbyte
(1024 bits)
W/\W/\W/ZNOTES.ORGces er
1.4. Binary Number System
Unsigned Binary
‘+ Binary that only represents positive whole numbers
‘+ Minimum value (for n bits) = 0
‘+ Maximum value (for n bits) = 2n-1
+ eg. maximum number in 8 bits = (241) = 255
igned binary: binary that represents a positive or
negative whole number
‘+ Adding unsigned binary: add the two numbers together
inbinary
+ Carrying a t: where the answer of 1+1 = 10, or 14141
1
‘+ Multiplying unsigned binary: multiply the binary by the
first digit ofthe second number. Repeat forthe next
ligt, shifting the answer along by 1. Then add che
resultant numbers together for the answer.
‘Two's Complement (Signed Binary)
‘+ Amethod that can be used to represent negative
Integers, where the most significant bits negative.
Converting to denary
‘+ An B-bittwo's complement number has -128 as the most
significant bit,
+ Write out denary equivalents (with sufficient columns
(Goubles each time) for the length ofthe binary
string)
+ Enter binary string in eg. 10071700)
+ Add up values (eg. = 100)
Converting from denary
W/\W/\W/ZNOTES.ORG
+ Flipthe bits and add 1
‘+ Write out the positive binary equivalent
+ eg, +102 = 01100110
pall bits
‘+ Perform binary addktion with 1 to get the answer
‘+ Computers can only add binary, soto perform the
calculation 20-13 = 20 + (-13)
+ 20=a0010100
213211110011
+ The answer can be checked by converting the final
answer into denary
‘+ Inthis case there is an overflow bit. tis handled
separately to the calculation
+ Calculate range: using bts, 256 numbers can be
represented (-128 to 127)
+ Arbitrary number of
represented
+ Unsigned binary: 2n- (as 0is representable)
+ Two's complement range
“+ Minimum representable value = (-2n-1),
‘+ Maximum representable value (2n-1-1)
2n numbers can be
Fractional Parts
Fixed point
‘+ Representing a fractional part using a fixed decimal
point. After the point, aigits become fractions
‘= Smallest representable number using 8-it fixed
point is 0900.0001 = 1/16 = 0.0625, 256 combinations
‘an be produced
‘+ Negative numbers can be made by making the MSB.
negative
+ eg (8) +4424 H+ O15
Floating pointces er
‘+ Representation of number where the decimalbinary
point moves, Uses two's complement
‘+ Mantissa: represents the significant digits (actual
value)
+ Exponent: represents the power to which a number
is raised to (how many places the points to move)
‘+ Floating point to decimal: 00001100 0011
+ Work out the exponent. Ifitis negative, the point in
the mantissa moves to the left. f positive, move to
the right.
+ 0011 = 43
|0}*+J0-]0-101111]0/0]
lolololojelti11ojoy
© Add colurnn headings to the mantissa and work out the
value. Any columns after the point are fractional.
005+0.25=0.75
+ Decimal to floating point: -10.5
+ Write out positive fixed point representation
oFlip the its and add 1 to get number into two's
complement
‘© Normalise the number by moving the point so that it starts
in 10 (fora positive number: 01)
Itfeloltsolti1 10104
O Fillin mantissa and exponent (number of places the point
moved)
It fort foiss4 ojo} [1poyoy
1.5. Binary Errors
W/\W/\W/ZNOTES.ORG
+ Rounding errors: it's not possible to represent every
decimal number, because fractions are being used -the
representation of some numbers may be inaccurate.
+ eg, 0.95 = 19/20, The binary progression of fractions.
allows us to get close, but never exact.
‘+ Some numbers (0.110) can never be accurately
represented.
‘+ Absolute rounding errors: the difference between the
value intended to be stored, and the actual value that
can be stores
+ Eg, 6.95 (target value) - 6.9375 (actual) = 0.0125
+ Relative rounding errors: percentage difference
between actual result and the expected result
‘relative error= (absolute valuey/(number intended to
be stored)
+ Ee, 0.0125/6.95 *1
Underftow and Overftow
18%
+ Will use erroneous results or a program crash. Can be
dealt with using flags
+ Underflow: when a number is too small o be
represented with the number of bits alocated
‘+ Example: representing 1/32 s impossible using &-bit
fixed point numbers - smallest that can be
represented is 1/16
+ Overflow: when a number is too bi
with the number of bits allocated
to be represented
‘+ Example: adding 00000001 (1) and 01171111 (127),
would praduce 10000000 (128), but in two's
complement, the answer would be 128
1.6. Floating Point vs. Fixed Pointces er
+ Range
+ Floating point can represent a wider range of
numbers with same number of bits as fixed point
+ Precision
+ Fixed point’s absolute error does not change
between numbers, so retains precision
+ Precision can vary wit floating point, asthe binary
point does not have a fixed position
+ Speed of calculation
+ Fixed point quicker to process, asthe binary point
does not need to be moved for each number
Normalisation of Floating Point
‘+ Normalisation adjusts numbers onto a common scale
that represents them as accurately as possible relative to
the number of bits available
Ensures that there is only one way to represent a
number
+ Positive normalised: must start with 0.1
‘+ Negative normalised: must start wi
1,7. Coding Systems
Character Form of Decimal
ch character has a character code, which is its
representation in binary
‘+ Decimal numbers can be represented either with a
character code or in pure binary
‘+ Character Code: used just to represent a number,
where the actual value is nat crucial lke ina phone
umber
‘+ Pure Binary: used to represent a number when
ns need to be performed, and the decimal
‘number will equal the binary value
ASCII and Unicode
+ ASCII: American Standard Code far Information
Incerchange. Introduced as a standard binary coding
system for characters and numbers
‘Standard: 7-bit code gives 128 permutations
+ Extended: #-bit code gives 256 permutations
‘+ Umitations: 256 characters not enough, no multi-
lingual support, web use requires universal coding
system, new programs need wider character range
+ Unicode: standard binary coding system that has
surpassed ASCII since it allows for more permutations
land hence more characters/languages. ASCII was
‘absorbed into Unicode, so all original codes remain the
same
‘+ UTF-16: 16-bit code allows characters for 20+
countries, special characters and emojs
‘Vitalin the age of international communication so
that data does not arive corrupted
1.8. Error Checking and Correction
+ Parity Bits: an adaltional bie added onto a binary string
‘to make total number of 1s/9s even or odd. Ina byte, 7
bits are sent + the adcitional parity bit
‘+ Even Parity: parity bit added to make total number
of 1s an even number. Checked on receiving end
+ Odd Parity: party bit added to make total number of
‘1s an odd number. Checked on receiving end
‘+ Majority Voting: each bit in a binary code Is sent a set
number of times, and then checking i the binary digit is
the same each time.
‘+ 10 sent as [4] = 11110000
+ Aninvalid transmission of 10 as [4] could be:
soro001
+ Checksums: isthe result ofa cryptographic hash
function ran on a piece of data to return a value. If the
value returned is equal to the value provided by the
‘source data, then transmission was successful
+ Check Digits: digit is added on the end of binary data to
check itis accurate, Modulo-11 is a common way to
calculate a check digit
‘Eg, 23045 is sent as 230456, so check digit is added,
and then ‘modded’ until the value reaches 0. If
calculation performed on receiving end does not
match, and error message is created
W/\W/\W/ZNOTES.ORG