Fundamentals of Data representation
Last edited time @November 8, 2023 9:06 AM
Status Done
Number systems
Natural numbers → a positive whole number including zero. The mathematical symbol is N. N = [0, 1, 2, 3...]
Integer → any whole positive or negative number including zero. The mathematical symbol is Z. Z =
[..., −3, −2, −1, 0, 1, 2, 3]
Rational number → any number that can be expressed as a fraction or ratio of integers. The mathematical symbol is Q
Irrational number → A number that cannot be represented as a fraction or ration as the decimal form will contain infinite
digits.
Real number → any positive or negative number with or without a fractional part. It is the set of all ‘possible real world
quantities’.
Ordinal number → A number used to identify position relative to other numbers, eg. 1st, 2nd ,3rd.
Cardinal number → A number that identifies the size of something.
Well-ordered set → A group of defined numbers with a defined order.
Array → A data structure where data items are grouped together under a single identifier and are then accessed based off
their position.
Number bases
Number base → the number of digits available within a particular number system e.g. 10 for denary and 2 for binary and 16
for hexadecimal.
Bit → A single digit in binary number, either 1 or 0. It is the fundamental unit of information. 2n different values can be
represented with nbits.
nibble → 4 bits.
byte → 8 bits.
Unit → The grouping of bits or bytes to form larger blocks of measurement, e.g. GB, MB. Below is a table of common binary
and decimal units.
Binary Decimal
Kibibyte - 2^10 kilobyte - 10^3
Mebibyte - 2^20 megabyte - 10^6
gibibyte - 2^30 gigabyte - 10^9
Tebibyte - 2^40 Terabyte - 10^12
The binary number system
unsigned binary → Binary number where each place value is 2 times larger than the previous. Cannot represent negative
numbers.
signed binary → Binary number where the most significant bit (largest place value) is a negative value. This means you can
calculate with negative numbers.
binary multiplication → It is the same process as with denary.
Underflow → When a number is too small to be represented with allocated number of bits.
Overflow → When a number is too large to be represented with the allocated number of bits.
Two’s complement
Fundamentals of Data representation 1
, two’s complement → A method for working with and representing signed binary numbers. The place value table is shown
below.
-128 64 32 16 8 4 2 1
Binary addition is the same with two’s complement as it is without. This allows us to carry out binary subtraction, which is
negative addition.
You can convert a positive binary number into two’s complement form by flipping the bits and adding 1.
With 8 bits, unsigned binary can represent 0 to 255 different numbers or, 2n − 1 where n =number of bits.
Two’s complement can only represent the range -128 to 127, or −2 n−1
to 2 n−1
− 1.
Fixed and floating point
To represent fractional parts in binary we use the following table.
-8 4 2 1 1/2 1/4 1/8 1/16
Two’s complement can also be used which would make the MSB (most significant bit) negative which the example above.
Some numbers cannot be represent, such as 0.6. So computers have to use precision with the number of allocated bits to
get as close to it as possible.
Fixed point binary → Allows representation of real numbers within binary. The binary point is in the same place. For
example, there may be 4 bits either side of the point.
Floating point binary → Where the decimal point can move within a number. This allows for a higher range of numbers
to be presented.
The binary is split into 2 sections:
Mantissa → The base of the number. Same as standard form.
Exponent → The number of places the decimal point will move.
For example with a 8 bit exponent and a 4 bit mantissa. 111101010010. 11110101 = mantissa and 0010 =
exponent.
To convert into a number into its floating point form:
Write out the number within fixed point form with place value table big enough to encompass the number.
Count how many places the decimal point has to move to make the mantissa < 1.
Write that number in two’s complement form.
Join together the two bits patterns to have the completed floating point form.
Fixed point compared to floating point
The advantages of using floating point are:
Can represented a much larger range of numbers with same number of bits.
Lends itself to programs that need to represent a large range of numbers.
The advantages of using fixed point are:
The values can be processed much faster as the binary point does not have to move.
Absolute error will always be the same.
Suited to programs were speed is very important.
Suited to programs were precision does not change for example finance and currency.
Normalisation and precision
Normalisation → A process for adjusting number onto a common scale. This is converting a binary number into standard
form.
Fundamentals of Data representation 2