Data Representation
Data Representation
Data Representation
01
Everything is Binary
Computers use 0s and 1s to represent
numbers, text, colours, images,
videos and everything else.
Computer Hardware is Logical
AND
B
Computer Hardware is Logical
AND
B
The same happens if only B is
switched on: the lightbulb
remains off.
Computer Hardware is Logical
But if both A and B are
switched on, the lightbulb A B X
turns on and lights up.
A 0 0 0
AND 1 0 0
B 0 1 0
We can model this operation 1 1 1
using a truth table.
…
○ 1
…
○ 100, 101, 110, 111
1111 1111
Have you heard of 256 colour images?
Everything is Binary
In 256 colour images (also known
as 8-bit colour), colours are
represented as single-byte words.
02
Binary Number System
Humans use the symbols 0-9 to represent
numbers. Computers use the symbols 0-1 to
represent numbers.
Denary Number System
1 2 3 6 7 8
Our number system is called
denary. 0 9
The prefix ‘den’ derives from 4 5
a Latin word meaning “ten
options”.
...and once you run out of numbers, you add 1 to the next column to
the left and reset the current column to 0.
256 128 64 32 16 8 4 2 1
0 1 0 1 1 0 0 0 1
128 + 32 + 16 + 1 = 177
Then we get the resulting denary number by simply adding the
columns which show a 1.
Denary to Binary
Converting from denary to binary is a little more involved.
256 128 64 32 16 8 4 2 1
214
Denary to Binary
Method 1: Left-to-right subtraction.
256 128 64 32 16 8 4 2 1
256 128 64 32 16 8 4 2 1
0
214
Denary to Binary
Method 1: Left-to-right subtraction.
256 128 64 32 16 8 4 2 1
0
256 128 64 32 16 8 4 2 1
0 1
86
Denary to Binary
Method 1: Left-to-right subtraction.
256 128 64 32 16 8 4 2 1
0 1
86 – 64 = 22; write 1.
Denary to Binary
Method 1: Left-to-right subtraction.
256 128 64 32 16 8 4 2 1
0 1 1
22
Denary to Binary
Method 1: Left-to-right subtraction.
256 128 64 32 16 8 4 2 1
0 1 1
256 128 64 32 16 8 4 2 1
0 1 1 0
22
Denary to Binary
Method 1: Left-to-right subtraction.
256 128 64 32 16 8 4 2 1
0 1 1 0
22 - 16 = 6; write 1.
Denary to Binary
Method 1: Left-to-right subtraction.
256 128 64 32 16 8 4 2 1
0 1 1 0 1
6
Denary to Binary
Method 1: Left-to-right subtraction.
256 128 64 32 16 8 4 2 1
0 1 1 0 1
256 128 64 32 16 8 4 2 1
0 1 1 0 1 0
6
Denary to Binary
Method 1: Left-to-right subtraction.
256 128 64 32 16 8 4 2 1
0 1 1 0 1 0
6 – 4 = 2; write 1.
Denary to Binary
Method 1: Left-to-right subtraction.
256 128 64 32 16 8 4 2 1
0 1 1 0 1 0 1
2
Denary to Binary
Method 1: Left-to-right subtraction.
256 128 64 32 16 8 4 2 1
0 1 1 0 1 0 1
2 – 2 = 0; write 1.
Denary to Binary
Method 1: Left-to-right subtraction.
256 128 64 32 16 8 4 2 1
0 1 1 0 1 0 1 1
0
Denary to Binary
Method 1: Left-to-right subtraction.
256 128 64 32 16 8 4 2 1
0 1 1 0 1 0 1 1
256 128 64 32 16 8 4 2 1
0 1 1 0 1 0 1 1 0
256 128 64 32 16 8 4 2 1
214
Denary to Binary
Method 2: Right-to-left division.
256 128 64 32 16 8 4 2 1
256 128 64 32 16 8 4 2 1
0
107
Denary to Binary
Method 2: Right-to-left division.
256 128 64 32 16 8 4 2 1
0
256 128 64 32 16 8 4 2 1
1 0
53
Denary to Binary
Method 2: Right-to-left division.
256 128 64 32 16 8 4 2 1
1 0
53 / 2 = 26 remainder 1; write 1.
Denary to Binary
Method 2: Right-to-left division.
256 128 64 32 16 8 4 2 1
1 1 0
26
Denary to Binary
Method 2: Right-to-left division.
256 128 64 32 16 8 4 2 1
1 1 0
26 / 2 = 13 remainder 0; write 0.
Denary to Binary
Method 2: Right-to-left division.
256 128 64 32 16 8 4 2 1
0 1 1 0
13
Denary to Binary
Method 2: Right-to-left division.
256 128 64 32 16 8 4 2 1
0 1 1 0
13 / 2 = 6 remainder 1; write 1.
Denary to Binary
Method 2: Right-to-left division.
256 128 64 32 16 8 4 2 1
1 0 1 1 0
6
Denary to Binary
Method 2: Right-to-left division.
256 128 64 32 16 8 4 2 1
1 0 1 1 0
6 / 2 = 3 remainder 0; write 0.
Denary to Binary
Method 2: Right-to-left division.
256 128 64 32 16 8 4 2 1
0 1 0 1 1 0
3
Denary to Binary
Method 2: Right-to-left division.
256 128 64 32 16 8 4 2 1
0 1 0 1 1 0
3 / 2 = 1 remainder 1; write 1.
Denary to Binary
Method 2: Right-to-left division.
256 128 64 32 16 8 4 2 1
1 0 1 0 1 1 0
1
Denary to Binary
Method 2: Right-to-left division.
256 128 64 32 16 8 4 2 1
1 0 1 0 1 1 0
1 / 2 = 0 remainder 1; write 1.
Denary to Binary
Method 2: Right-to-left division.
256 128 64 32 16 8 4 2 1
1 1 0 1 0 1 1 0
0
Denary to Binary
Method 2: Right-to-left division.
256 128 64 32 16 8 4 2 1
1 1 0 1 0 1 1 0
256 128 64 32 16 8 4 2 1
0 1 1 0 1 0 1 1 0
83 S
We know now how to represent
numbers.
01010011 (Well, we know how to represent
positive whole numbers.)
101100001111001100000101
But how should a given 24-bit
binary word relate to a colour?
Representing Colour
What if we just list all the
colours?
(176)
Recap:
10 (243)possible
How many 10 (5)10
values
are there for a byte? 256
Here’s The
Secret of
Monkey Island
in 1-bit,
2-bit, 4-bit
and 8-bit
colour.
83 S
We know now how to represent
All of them?
21,815,360
= 2.73 MB
bits
Representing Text
Sometimes, we need to be able to
use more than 128 characters.
For example, there are thousands
of unique Chinese characters.
04
Computation with Binary Numbers
We know how to store binary numbers as
different kinds of data. But how do we perform
logical and arithmetic operations on them?
Quick Recap
We’ve introduced the binary number system,
and seen how binary can be used to
represent colours and text.
A B A AND B
0 0 0
101 ?
0100 1 0 0
AND
OR 0 1 0
0110
1 1 1
A B A OR B
0 0 0
101 ?
0100 1 0 1
AND
OR 0 1 1
0110
1 1 1
A OR B = 1 only when
either A = 1 and B = 1.
Binary Logic
The OR operation on bits also
does exactly what it says.
A B A OR B
0 0 0
101 ?
0100 1 0 1
AND
OR 0 1 1
0110
0110
1 1 1
A B A AND B
0 0 0
0101 0100
0100 1 0 0
AND
OR 0 1 0
0110
0110
1 1 1
A NOT A A B A XOR B
0 1 0 0 0
1 0 1 0 1
0 1 1
1 1 0
Binary Computation
1
…and add them digit-by-digit
(remembering to carry).
Binary Arithmetic – Addition
In order to do this, we had to
know how to add digits themselves.
A B A+B
Result Carry
0 0 0 0
1 0 1 0
0 1 1 0
1 1
A B A+B
Result Carry
0 0 0 0
1 0 1 0
0 1 1 0
1 1
A B A+B
Result Carry
0 0 0 0
1 0 1 0
0 1 1 0
1 1 0 1
A B A+B
Result Carry
0 0 0 0
1 0 1 0
0 1 1 0
1 1 0 1
A B A+B
Result Carry
0 0 0 0
1 0 1 0
0 1 1 0
1 1 0 1
A B A+B
Result Carry
0 0 0 0
1 0 1 0
0 1 1 0
1 1 0 1
A B A+B
Result Carry
0 0 0 0
1 0 1 0
0 1 1 0
1 1 0 1
A B A+B
Result Carry
0 0 0 0
1 0 1 0
0 1 1 0
1 1 0 1
A B A+B
Result Carry
0 0 0 0
1 0 1 0
0 1 1 0
1 1 0 1
A B A+B
Result Carry
0 0 0 0
1 0 1 0
0 1 1 0
1 1 0 1
A B A+B
Result Carry
0 0 0 0
1 0 1 0
0 1 1 0
1 1 0 1
1
…and then we add bit-by-bit
(remembering to carry).
Binary Arithmetic – Addition
So, to compute 105 + 28 in binary,
let’s first convert 105 and 28
from denary…
A B A+B
Result Carry
0 0 0 0
1 0 1 0
0 1 1 0
1 1 0 1
1
…and then we add bit-by-bit
(remembering to carry).
Binary Arithmetic – Addition
So, to compute 105 + 28 in binary,
let’s first convert 105 and 28
from denary…
A B A+B
Result Carry
0 0 0 0
1 0 1 0
0 1 1 0
1 1 0 1
1
…and then we add bit-by-bit
(remembering to carry).
Binary Arithmetic – Addition
So, to compute 105 + 28 in binary,
let’s first convert 105 and 28
from denary…
A B A+B
Result Carry
0 0 0 0
1 0 1 0
0 1 1 0
1 1 0 1
1
…and then we add bit-by-bit
(remembering to carry).
Binary Arithmetic – Addition
So, to compute 105 + 28 in binary,
let’s first convert 105 and 28
from denary…
A B A+B
Result Carry
0 0 0 0
1 0 1 0
0 1 1 0
1 1 0 1
1
…and then we add bit-by-bit
(remembering to carry).
Binary Arithmetic – Addition
So, to compute 105 + 28 in binary,
let’s first convert 105 and 28
from denary…
A B A+B
Result Carry
0 0 0 0
1 0 1 0
0 1 1 0
1 1 0 1
1
…and then we add bit-by-bit
(remembering to carry).
Binary Arithmetic – Addition
So, to compute 105 + 28 in binary,
let’s first convert 105 and 28
from denary…
A B A+B
Result Carry
0 0 0 0
1 0 1 0
0 1 1 0
1 1 0 1
1
…and then we add bit-by-bit
(remembering to carry).
Binary Arithmetic – Addition
So, to compute 105 + 28 in binary,
let’s first convert 105 and 28
from denary…
A B A+B
Result Carry
0 0 0 0
1 0 1 0
0 1 1 0
1 1 0 1
1
…and then we add bit-by-bit
(remembering to carry).
Binary Arithmetic – Addition
So, to compute 105 + 28 in binary,
let’s first convert 105 and 28
from denary…
A B A+B
Result Carry
0 0 0 0
1 0 1 0
0 1 1 0
1 1 0 1
= 133
…and then we add bit-by-bit
(remembering to carry).
Binary Arithmetic – Addition
What should we do in this situation? What is 1 + 1 + 1 ?
Note that the last two bits have now been completely lost, because
we can currently only represent whole numbers. The right bit shift
therefore performs an integer division, rather than a real
division.
Binary Arithmetic – Overflow
Thus far, we have implicitly assumed that we have an unlimited
number of bits available for each number – just like we do in real
life when writing on paper or a whiteboard!
(Feel free to look into it and let me know if you find out how it works.)
Binary Arithmetic – Subtraction
The final arithmetic operation we would like to introduce is
subtraction.
05
Representing Negative Numbers
Let’s explore how we represent numbers below
zero. By doing this, we will illuminate how
to perform subtraction on binary numbers.
Representing Negative Numbers
Let’s say that our computer represents numbers as single-byte
(8-bit) binary words using the usual binary representation.
128 64 32 16 8 4 2 1
1 1 1 1 1 1 1 1
Representing Negative Numbers
Let’s say that our computer represents numbers as single-byte
(8-bit) binary words using the usual binary representation.
128 64 32 16 8 4 2 1
0 0 0 0 0 0 0 0
Representing Negative Numbers
The int datatype includes both positive and negative numbers, but the
representation we have explored only represents positive numbers.
128 64 32 16 8 4 2 1
– 64 32 16 8 4 2 1
1 1 1 0 0 1 0 0
The remaining bits are the magnitude of the number: they represent
the absolute value of the represented number in the usual way.
– 64 32 16 8 4 2 1
1 1 1 0 0 1 0 0
100
The magnitude of the number is 100.
Negative Numbers – Sign-and-magnitude
In the sign-and-magnitude representation, the MSB (in this 8-bit
case, 2^7) instead becomes a sign bit.
– 64 32 16 8 4 2 1
1 1 1 0 0 1 0 0
– 100
The magnitude of the number is 100.
– 64 32 16 8 4 2 1
1 1 1 0 0 1 0 0
– 100
The represented number is -100.
Negative Numbers – Sign-and-magnitude
In the sign-and-magnitude representation, the MSB (in this 8-bit
case, 2^7) instead becomes a sign bit.
– 64 32 16 8 4 2 1
0 1 1 0 0 1 0 0
100
The represented number is -100.
If the sign bit had been 0, then the represented number would have
been 100.
Negative Numbers – Sign-and-magnitude
– 64 32 16 8 4 2 1
1 1 1 1 1 1 1 1
Mathematically, sign-and-
magnitude isn’t ideal: it doesn’t
let us define subtraction!
Mathematically, sign-and-
magnitude isn’t ideal: it doesn’t
let us define subtraction!
Mathematically, sign-and-
magnitude isn’t ideal: it doesn’t
let us define subtraction!
Mathematically, sign-and-
magnitude isn’t ideal: it doesn’t
let us define subtraction!
Mathematically, sign-and-
magnitude isn’t ideal: it doesn’t
let us define subtraction!
–128 64 32 16 8 4 2 1
1 1 1 0 0 1 0 0
-128 + 64 + 32 + 4
Which denary number is represented by the two’s complement
binary number 11100100?
Negative Numbers – Two’s complement
In the two’s complement representation, the MSB (in this 8-bit
case, 2^7) represents the negated form of the original MSB.
–128 64 32 16 8 4 2 1
1 1 1 0 0 1 0 0
-28
The represented number is -28.
Negative Numbers – Two’s complement
In the two’s complement representation, the MSB (in this 8-bit
case, 2^7) represents the negated form of the original MSB.
–128 64 32 16 8 4 2 1
0 1 1 0 0 1 0 0
100
The represented number is -28.
If the MSB had been 0, then the represented number would have been
100.
Negative Numbers – Two’s complement
–128 64 32 16 8 4 2 1
1 0 0 0 0 0 0 0
–128 64 32 16 8 4 2 1
–128 64 32 16 8 4 2 1
0 1 0 1 0 0 0 1
–128 64 32 16 8 4 2 1
1 0 1 0 1 1 1 0
–128 64 32 16 8 4 2 1
1 0 1 0 1 1 1 1
–128 64 32 16 8 4 2 1
1 0 1 0 1 1 1 1
Mathematically, sign-and-
magnitude isn’t ideal: it doesn’t
let us define subtraction!
Mathematically, sign-and-
magnitude isn’t ideal: it doesn’t
let us define subtraction!
Mathematically, sign-and-
magnitude isn’t ideal: it doesn’t
let us define subtraction!
06
Representing Real Numbers
Finally, let’s explore how we represent
numbers with a decimal point.
Representing Real Numbers
The float datatype includes both positive and negative fractional
numbers, but the representations we have explored thus far have only
represented whole numbers (also called integers).
16 4 2 1 0.25 0.125
16 8 4 2 1 0.5 0.25 0.125
1 0 1 1 1 0 1 1
16 + 4 + 2 + 1 + 0.25 + 0.125
16 8 4 2 1 0.5 0.25 0.125
1 0 1 1 1 0 1 1
23.375
16 8 4 2 1 0.5 0.25 0.125
1 0 1 1 1 0 1 1
0.625
Real Numbers – Fixed point
For the fractional part, we do the opposite: we go left-to-right
and multiply by 2 rather than divide by 2.
0.25
Real Numbers – Fixed point
For the fractional part, we do the opposite: we go left-to-right
and multiply by 2 rather than divide by 2.
0.5
Real Numbers – Fixed point
For the fractional part, we do the opposite: we go left-to-right
and multiply by 2 rather than divide by 2.
0 reached!
Real Numbers – Fixed point
Another way to understand fixed point binary numbers is as
scaled binary integers.
X = B * 2i (or X = B << i)
The number 3.5 can be 8 4 2 1 0.5 0.25 0.125
represented as 0011100. L
0 0 1 1 1 eft sh0 0
i ft b
y3
In the usual positive
64 32 16 8 4 2 1
integer representation,
this would be the number 0 0 1 1 1 0 0
28…
– 64 32 16 8 4 2 1 0.5 0.25
Real Numbers – Fixed point
Of course, we can also represent negative real numbers.
– 64 32 16 8 4 2 1 0.5 0.25
1 0 1 1 1 0 1 1 0 1
Real Numbers – Fixed point
Of course, we can also represent negative real numbers.
There are many ways of doing this. Here’s how I worked this out:
● -0.533203125 * 29 = -273
Real Numbers – Fixed point
Of course, we can also represent negative real numbers.
There are many ways of doing this. Here’s how I worked this out:
● -0.533203125 * 29 = -273
● 273 in standard 10-bit binary = 0100010001 (using left-to-right method)
Real Numbers – Fixed point
Of course, we can also represent negative real numbers.
There are many ways of doing this. Here’s how I worked this out:
● -0.533203125 * 29 = -273
● 273 in standard 10-bit binary = 0100010001 (using left-to-right method)
● Flip all bits and add 1 to convert to two’s complement
Real Numbers – Fixed point
Of course, we can also represent negative real numbers.
There are many ways of doing this. Here’s how I worked this out:
● -0.533203125 * 29 = -273
● 273 in standard 10-bit binary = 0100010001 (using left-to-right method)
● Flip all bits and add 1 to convert to two’s complement
Real Numbers – Fixed point
Fixed point isn’t perfect for representing real numbers.
0 0 0 0 1
0 0 0 0 1
For example:
For example:
m e
The representation can be split into two parts: the part that
represents m and the part that represents e.
In general, the mantissa m needs to have a higher number of
bits than the exponent e, so let’s have a 12-bit mantissa and a
4-bit exponent.
Real Numbers – Floating point
There are now three problems we need to deal with:
1. How should we represent the mantissa?
2. How should we represent negative numbers?
3. How should we represent the exponent?
m e
Real Numbers – Floating point
In our examples of both denary and binary scientific notation,
m was always normalised: this means it always had exactly one
digit/bit before the decimal/binary point.
m e
m e
We could simply remember that numbers should start with 1. and
effectively hide this extra bit.
(This does mean we now can’t represent zero, but we will fix this later.)
Real Numbers – Floating point
1. How should we represent the mantissa?
2. How should we represent negative numbers?
3. How should we represent the exponent?
4. How should we represent zero?
m e
Real Numbers – Floating point
Floating point numbers represent negative numbers by using a
sign bit.
sign m e
This sign bit gives the sign of the mantissa (and therefore the
overall represented number), not the exponent.
sign m e
Real Numbers – Floating point
The exponent needs to be able to take on both positive and negative
values. So, presumably, it either needs its own sign bit or to be
stored in two’s complement.
sign m e
However, both have their issues. In particular, they both cause
binary numbers to be ordered incorrectly relative to the ordering
on the representing bit-strings.
First, the exponent needs to come after the sign bit and before m.
sign e* m
Secondly, as introduced in 1954 with the IBM 704, the exponent
needs to be stored with an offset.
Sign-and-
magnitude
representation
Two’s
complement
representation
Offset/biased
representation
when b = 3
Real Numbers – Floating point
An offset exponent, sometimes called a biased exponent, is used
instead of two’s complement so that the representations of negative
numbers are ordered earlier than the representations of positive
numbers.
sign e* m
Given a bias b, the true exponent e can be computed from the offset
exponent e* by calculating e = e* - b (thus also e* = e + b).
sign e* m
Real Numbers – Floating point
Because of the hidden bit, zero cannot be represented.
–
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
sign e* m
Zero is one of these special values: it is represented by a 0 sign
bit, 0 biased exponent and 0 mantissa.
Real Numbers – Floating point
Other special values include +∞, -∞ and NaN.
Positive and negative infinity are the values which occur when
floating point numbers overflow or underflow (respectively).
–
0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0
sign e* m
+∞ is represented as a 0 sign bit, all 1s biased exponent and 0
mantissa.
Real Numbers – Floating point
Other special values include +∞, -∞ and NaN.
Positive and negative infinity are the values which occur when
floating point numbers overflow or underflow (respectively).
–
1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0
sign e* m
-∞ is represented as a 1 sign bit, all 1s biased exponent and 0
mantissa.
Real Numbers – Floating point
Other special values include +∞, -∞ and NaN.
–
0 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1
sign e* m
NaN is represented as any sign bit, all 1s biased exponent and any
mantissa except 0.
Real Numbers – Floating point
The standard for floating point arithmetic is IEEE 754. It consists
of the features we introduced: a sign bit, a biased exponent, a
mantissa with a hidden bit and special values such as +∞, -∞ and
NaN.
sign e* m
IEEE 754 usually has one of the following precisions:
● Single precision (32-bit numbers with 8-bit exponent)
● Double precision (64-bit numbers with 11-bit exponent)
Real Numbers – Floating point
Let’s do some examples with our hypothetical 16-bit (4-bit
exponent) IEEE 754 representation, with an exponent bias of b = 7.
sign e* m
Real Numbers – Floating point
Let’s do some examples with our hypothetical 16-bit (4-bit
exponent) IEEE 754 representation, with an exponent bias of b = 7.
sign e* m
The sign bit is 1,
Real Numbers – Floating point
Let’s do some examples with our hypothetical 16-bit (4-bit
exponent) IEEE 754 representation, with an exponent bias of b = 7.
sign e* m
The sign bit is 1, so it’s a negative number.
Real Numbers – Floating point
Let’s do some examples with our hypothetical 16-bit (4-bit
exponent) IEEE 754 representation, with an exponent bias of b = 7.
sign e* m
The sign bit is 1, so it’s a negative number.
The biased exponent is 6,
Real Numbers – Floating point
Let’s do some examples with our hypothetical 16-bit (4-bit
exponent) IEEE 754 representation, with an exponent bias of b = 7.
sign e* m
The sign bit is 1, so it’s a negative number.
The biased exponent is 6, so the true exponent is 6 - 7 = -1.
Real Numbers – Floating point
Let’s do some examples with our hypothetical 16-bit (4-bit
exponent) IEEE 754 representation, with an exponent bias of b = 7.
sign e* m
The sign bit is 1, so it’s a negative number.
The biased exponent is 6, so the true exponent is 6 - 7 = -1.
The mantissa with the hidden bit is
Real Numbers – Floating point
Let’s do some examples with our hypothetical 16-bit (4-bit
exponent) IEEE 754 representation, with an exponent bias of b = 7.
sign e* m
The sign bit is 1, so it’s a negative number.
The biased exponent is 6, so the true exponent is 6 - 7 = -1.
The mantissa with the hidden bit is (1.01100110000)2.
Real Numbers – Floating point
Let’s do some examples with our hypothetical 16-bit (4-bit
exponent) IEEE 754 representation, with an exponent bias of b = 7.
20 2-1 2-2 2-3 2-4 2-5 2-6 2-7 2-8 2-9 2-10 2-11 2-12 2-13 2-14 2-15
20 2-1 2-2 2-3 2-4 2-5 2-6 2-7 2-8 2-9 2-10 2-11 2-12 2-13 2-14 2-15
0 1 0 1 1 0 0 1 1 0 0 0 0 0 0 0
20 2-1 2-2 2-3 2-4 2-5 2-6 2-7 2-8 2-9 2-10 2-11 2-12 2-13 2-14 2-15
0 1 0 1 1 0 0 1 1 0 0 0 0 0 0 0
20 2-1 2-2 2-3 2-4 2-5 2-6 2-7 2-8 2-9 2-10 2-11 2-12 2-13 2-14 2-15
0 1 0 1 1 0 0 1 1 0 0 0 0 0 0 0
sign e* m
Real Numbers – Floating point
Let’s do some examples with our hypothetical 16-bit (4-bit
exponent) IEEE 754 representation, with an exponent bias of b = 7.
sign e* m
Convert it to fixed point:
Real Numbers – Floating point
Let’s do some examples with our hypothetical 16-bit (4-bit
exponent) IEEE 754 representation, with an exponent bias of b = 7.
sign e* m
Convert it to fixed point: 10001110.1.
Real Numbers – Floating point
Let’s do some examples with our hypothetical 16-bit (4-bit
exponent) IEEE 754 representation, with an exponent bias of b = 7.
sign e* m
Convert it to fixed point: 10001110.1.
Write it in normalised scientific notation:
Real Numbers – Floating point
Let’s do some examples with our hypothetical 16-bit (4-bit
exponent) IEEE 754 representation, with an exponent bias of b = 7.
sign e* m
Convert it to fixed point: 10001110.1.
Write it in normalised scientific notation: (1.00011101)2 * 27.
Real Numbers – Floating point
Let’s do some examples with our hypothetical 16-bit (4-bit
exponent) IEEE 754 representation, with an exponent bias of b = 7.
sign e* m
Convert it to fixed point: 10001110.1.
Write it in normalised scientific notation: (1.00011101)2 * 27.
The mantissa is therefore
Real Numbers – Floating point
Let’s do some examples with our hypothetical 16-bit (4-bit
exponent) IEEE 754 representation, with an exponent bias of b = 7.
sign e* m
Convert it to fixed point: 10001110.1.
Write it in normalised scientific notation: (1.00011101)2 * 27.
The mantissa is therefore 00011101.
Real Numbers – Floating point
Let’s do some examples with our hypothetical 16-bit (4-bit
exponent) IEEE 754 representation, with an exponent bias of b = 7.
sign e* m
Convert it to fixed point: 10001110.1.
Write it in normalised scientific notation: (1.00011101)2 * 27.
The mantissa is therefore 00011101.
The true exponent is 7, so the biased exponent is
Real Numbers – Floating point
Let’s do some examples with our hypothetical 16-bit (4-bit
exponent) IEEE 754 representation, with an exponent bias of b = 7.
sign e* m
Convert it to fixed point: 10001110.1.
Write it in normalised scientific notation: (1.00011101)2 * 27.
The mantissa is therefore 00011101.
The true exponent is 7, so the biased exponent is 7 + 7 = 14.
Real Numbers – Floating point
Let’s do some examples with our hypothetical 16-bit (4-bit
exponent) IEEE 754 representation, with an exponent bias of b = 7.
sign e* m
Convert it to fixed point: 10001110.1.
Write it in normalised scientific notation: (1.00011101)2 * 27.
The mantissa is therefore 00011101.
The true exponent is 7, so the biased exponent is 7 + 7 = 14.
The number is positive, so the sign bit is 0.
Real Numbers – Floating point
Let’s do some examples with our hypothetical 16-bit (4-bit
exponent) IEEE 754 representation, with an exponent bias of b = 7.
sign e* m
Convert it to fixed point: 10001110.1.
Write it in normalised scientific notation: (1.00011101)2 * 27.
The mantissa is therefore 00011101.
The true exponent is 7, so the biased exponent is 7 + 7 = 14.
The number is positive, so the sign bit is 0.
Real Numbers
0 0 0 0 1
Real Numbers
2-1 2-2 2-3 2-4 2-5 2-6 2-7 2-8 2-9 2-10 2-11 2-12 2-13 2-14 2-15 …
0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 …
Real Numbers
02 Binary is the base 2 number system that consists only of 0s and 1s.
Chapter 1: Introduction
Office Hours:
10:00-12:00 Wednesdays in CS/109