Please enable JavaScript.
Coggle requires JavaScript to display documents.
Data Representation (4.5) - Coggle Diagram
Data
Representation
(4.5)
Numbers
Natural Numbers
A positive whole number that is used for counting
E.g. "0, 1, 2, 3 ,4" represented by the symbol
N
Integer Numbers
A positive/negative whole number
E.g. "-3, -2, 0, 2, 5" represented by the symbol
Z
Rational Numbers
Any number which can be expressed as a ratio or fraction
A/B - e.g. "1/5, 3/1, 9/2" represented by the symbol
Q
Real Numbers
Any possible real world quantity expressed as a number
Numbers used for measurements, it includes
Q
,
Z
and
N
Inc. virtually all possible numbers e.g. "π"; symbol -
R
Ordinal Numbers
A number used to describe the numerical position of objects
e.g. "Second, Third etc."
Number
Systems
Denary
Base-10 number system, 0-9
e.g."123434, 177013, 10, 2"
Binary
Base-2 number system, 0-1
e.g. "0101, 1111, 10, 1"
Hexadecimal
Base-16 number sysem, 0-F
Each number can be thought to represent a nibble,
hexadecimals are usually grouped into pairs
e.g."A0, B3, D6" (easier to read than binary)
Most colours represented by 24-bit string so are
converted into 3 hexadecimal pairs, for RGB
Unit
Representation
Bits
In computing devices, the fundamental unit of info is the bit
There's no smaller unit, a single bit can be either 1/0
It can be represented w/ e-current or a 2-state circuit:
the current is flowing/not flowing; on/off; hi voltage/lo voltage
A computer at the most basic level can only understand 1/0
There are 2^n possible variations w/ n bits
4 bits = nibble, 8 bits = byte;
Standard Form (kinda)
kibi (Ki) = 2^10 = 1,024
mebi (Mi) = 2^20 = 1,048,576
gibi (Gi) = 2^30 = 1,073,741,824
tebi (tebi) = 2^40 = 1,099,511,627,776
Standard Form pt 2
Kilo (K) = 10^3 = 1,000
Mega (M) = 10^6 = 1,000,000
Giga (G) = 19^9 = 1,000,000,000
Tera (T) = 10^12 = 1,000,000,000,000
Peta (P) = 10^15; Exa (E) = 10^18
Zetta (Z) = 10^21 = Yotta (Y) = 10^24
Unsigned
Binary
Maximum and Minimum
The max. and min. values which can be stored using
unsigned binary, in n bits is 0 and 2^(n-1) respectively
So for the 8-bit range of values 0-255
The min. value = 0, the max. value = 255
(0 is considered a positive number)
Arithmetics
1 + 0 = 1
1 + 1 = 10 (0 carry 1)
1 + 0 carry 1 = 10 (0 carry 1)
1 + 1 carry 1 = 11 (1 carry 1)
Arithmetics pt 2
1 - 0 = 1
0 - 1 = 1 (take 10)
1 - 0 take 10 = 0
1 - 1 take 10 = 1 (take 10)
0 - 0 take 10 = 1 (take 10)
0 - 1 take 10 = 0 (take 10)
Multiplication
Times by power of 2 (2^n) = shift by n bits left
Otherwise split multiplier into powers of 2
e.g. 24 * 10 = 24 * (8 + 2)
Two's
Complement
Definition
The most significant bit is negative
e.g. byte - the last first bit becomes -128
Normal: 1011 0100 = 128+32+16+4 = 180
2's Comp: 1011 0100 = (-128)+32+16+4 = -76
Negative Conversion
0011 1100 = 60
Method 1:
flip all the bits except for the last '1' bit
and the subsequent bits;
e.g. 0011 1100 = 1100 0100
Method 2:
flip all the bits, then add 1 to the new byte
e.g. 0011 1100 = 1100 0011 + '1' = 1100 0100
End Result:
0011 1100 = 32+16+8+4 = 60
1100 0100 = -128+64+4 = -60
Addition
Works with 2's complement
e.g. 12 - 5 = 12 + (-5)
Floating
Point
Prerequisites
More often then not, computers used
2's complement to store integers
Generally has form "-16,8,4,2,1,½,¼..."
Representation
Composes of Mantissa and Exponent
Mantissa - actual number you want to store
Exponent - position of the binary point in the number
Usually 5 bits for the Mantissa, 3 bits for the Exponent
The binary point in the Mantissa immediately after 1st bit
Exponent says how much to move point to the right
Both are naturally stored as 2's complement
Normalisation
All negative numbers start with '10'
All positive numbers start with '01'
(In the mantissa) if the exponent change
reveals new place holders, fill these places
with the first bit; e.g. 01000 110 (Exponent = -2)
Final No. = 0.001 0000 = 1/8
e.g. 10000 111 (Exponent = -3)
Final No. = 1.111 0000 = -1 + ½ + ¼ + ⅛ = -⅛
Fill with '1's for negatives; Fill with '0's for positives
Aboslute
& Relative
Errors
The Big Problem
Some numbers can never be represented
with complete accuracy in computers of
significatn importance
Currency Exchange: Most currency exchange
multipliers fluctuate randomly and thus computers
can't compute exactly the correct number;
e.g. 0.1 can't be represented exactly due to floating point
we inevitably loose/accumulate actual money in
digital commerce
Absolute Error
The difference between the number you're trying to represent and the actual number that is the closest
possible approximation in the format given
E.g. Closest possible for 0.1 in given format = 0.09375
|error| = 0.1 - 0.09375 = 0.00625
Relative Error
The percentage difference of the error: the |error|
divided by the desired number
0.00625/0.1 = 0.0625 = 6.25%
Effect of Magnitude on Errors
The significance of an
absolute/relative
error can
change
massively depending on the
situation
and
the
magnitude
of the numbers involved
Fixed Point
v
Floating Form
Range:
Depends on position of binary point -
range is traded for precision
Easily represent large range and large precision
More bits used for exponent = greater range
Precision:
Depends on position of binary point -
precision is traded for range
Allows greater range of no. when using same
no. of bits; More bits for mantissa = greater precision
Calculation Speed:
Fixed point is simpler to calc.
the processing speed tends to be faster
Floating point has to be moved, some CPUs have
access to hardware float point circuitry, still takes
longer to calc. and process in general
Overflow
& Underflow
Underflow
Occurs if a number is to small to be represented
in format provided
, number is repr. as '0' instead.
Overflow
Occurs if the result of a calculation is to large
to be held in the format provided
; with 2's complement
the number becomes negative, e.g. 118 + 33 = 151
But with a 8-bit 2's comp. format ,the answer is '-105'
Character Sets
ASCII
American Standard Code for Information Interchange
Usually only 7-bits (128) used, the last bit for error checking
Most personal computers use ASCII, computers need the same character set to communicate readable messages
Unicode: Universal Code
128/256 combinations is not enough to cover all language
symbols used in the modern world, also including emojis
At least 16-bits long; now +2x more space is needed to represent each character
Error
Checking
Parity Bits
Computers submit data in 'bytes' (8-bits)
Normal ASCII don't use the most sig. bit
This can be used as parity bit
Odd parity - bit makes sure there's odd amount of '1's
Even parity - bit makes sure there's even amount of '1's
Majority Voting
Crude method of ID'ing errors in data; transmit same
binary digit multiple times (a block), look at pattern received
If the pattern has doesn't match, majority voting checks
the most frequent bit in each bot and that the correct one.
Check Digits
Form of redundancy check used for error detection on ID no.
e.g. bank account numbers in app. where they're sometimes
inputed manually
...
ISBN-10 number system for books
uses 'Modulo-11' process to create check digit (last no.)
Checksums
A mathematical algorithm applied to a block of data
Data from block creates init. checksum, added and transmitted along with the origin. data; on receiving data,
if checksum matches data sum = successful transmit