Understand Two’s complement, how to calculate range of numbers representable in binary
Understand how to use floating point representation with binary
Understand what Unicode is and the pros and cons of it
Understand the difference between binary and vector graphics
The binary system is the way in which a computer represents positive and negative whole numbers.
Binary is a two state system which means numbers are represented using a series of 1s and 0s
1 meaning a voltage is present and a 0 meaning a voltage is not present - specifically transistors turn on at around 0.7 volts
At National 5 level, we only had to deal with positive numbers, but at higher we need to know how to convert positive and negative numbers
Let’s figure out what the binary number 1001 means in denary:
To do this, add each number with a 1 under it together, so 8 + 1. Total is 9. So 1001 = 9.
23 | 22 | 21 | 20 |
---|---|---|---|
8 | 4 | 2 | 1 |
1 | 0 | 0 | 1 |
Convert:
1000 1000
To denary.
Convert:
1100 1111
To denary.
Convert:
0010 0100
To denary.
Reversing binary to give us a decimal number is a bit trickier. The placeholders are the same and should be put at the top. Hint: the leftmost placeholder should be no bigger than the denary number.
Let’s calculate the number 17:
16 | 8 | 4 | 2 | 1 |
---|---|---|---|---|
1 | 0 | 0 | 0 | 1 |
Now let’s calculate 35:
Double check it by adding all the numbers with a 1 under them together.32 + 2 + 1 = 35
32 | 16 | 8 | 4 | 2 | 1 |
---|---|---|---|---|---|
1 | 0 | 0 | 0 | 1 | 1 |
Convert:
28
To 8-bit binary
Convert:
32
To 8-bit binary
Convert:
254
To 8-bit binary
Fewer arithmetic operations
Any slight voltage drop does not change the data.
Imagine trying to represent 0 to 9 with discrete voltages!
Just use zero volts = 0, any volts = 1
Two state storage is easy in storage devices such as CDs
Large number of digits required for even moderately large numbers
E.g. 1000 0000 0000 = 4096
(12 digits) (4 digits)
Previously, we’ve only had to deal with positive numbers, but how does a computer represent negative whole numbers?
We use Two’s complement (note the spelling of complement).
Two’s compliment allows us to represent both positive and negative numbers and there’s two methods to do it.
This method is carried out using three steps.
Let’s convert -116 using 8-bit Two’s complement
Step 1– Find positive 116 in Binary
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
---|---|---|---|---|---|---|---|
0 | 1 | 1 | 1 | 0 | 1 | 0 | 0 |
64 + 32 + 16 + 4 = 116
Step 2 - Switch all the 1s and 0s:
Our next step is to switch the 1s and 0s around.
In a Two’s complement number if the left most bit is 1 then its a negative number, if it’s a 0 then it’s a positive number.
-128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
---|---|---|---|---|---|---|---|
1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 |
Notice that the 128 has become -128. This helps with the next bit
Step 3 - Add 1
We need to move to the right hand side and add a 1 where we see our first 0 and then replace the 1s with a 0
-128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
---|---|---|---|---|---|---|---|
1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 |
This becomes 1
These become 0
-128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
---|---|---|---|---|---|---|---|
1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 |
That method isn't the only method, there are actually several.
The first method has a lot of steps involved in it.
The second method is easier and can also be used as a verification technique if you do choose to use the first method.
Step 1 - Start negative
Start with your column headings. Make sure you’re left most bit (128) is negative!
-128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
---|---|---|---|---|---|---|---|
-128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
---|---|---|---|---|---|---|---|
1 |
Step 3 - Make 116
Put 1s under each of the numbers that added to -128 make up -116.
-128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
---|---|---|---|---|---|---|---|
1 | 1 | 1 |
-128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
---|---|---|---|---|---|---|---|
1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 |
Calculate the following numbers using 8 bit Two’s complement.
-120
-85
-4
-1
32
1010 1011
1111 1111
1000 1000
0010 0000
1111 1100
Convert the following 8-bit two’s complement number into denary.
1001 1010
1 mark
2019 Q1
-102
Complete the Two's complement task sheet
-128 to 127
Calculate the range of numbers that can be represented using Two’s Compliment if you have:
-512 to 511
-2,048 to 2,047
-32,768 to 32,767
-8,388,608 to 8,388,607
Complete the Range of Numbers task sheet
This is the same number as 54934.33239
Answer the following questions:
1500711
5
The current meter reading of 15007.11 would be stored in a computer system using floating-point representation as shown below.
0.1500711 x 105
Identify the mantissa and exponent in the above floating-point representation.
Mantissa ____________________________________________________
Exponent ___________________________________________________
2 marks
The number 20.125 can be represented as .20125 x 102
20.125 can be represented as .20125 x base places point moved
But a computer works in Binary so:
20.125 = 10100.001
∴ 10100001 x 25
At Higher level you will be given a real binary number and be asked to identify the mantissa and exponent.
We are going to start by converting real numbers into binary.
Let's convert 10.75 to floating point.
8 | 4 | 2 | 1 | • | ||||
---|---|---|---|---|---|---|---|---|
1 | 0 | 1 | 0 | • |
First calculate 10 and add the decimal point
8 | 4 | 2 | 1 | • | 0.5 | 0.25 | 0.125 | 0.625 |
---|---|---|---|---|---|---|---|---|
1 | 0 | 1 | 0 | • | 1 | 1 | 0 | 0 |
Now figure out the bit after the decimal place
Convert the following decimal numbers into Binary.
8 | 4 | 2 | 1 | • | 0.5 | 0.125 | 0.625 | ||
---|---|---|---|---|---|---|---|---|---|
10.5 | 1 | 0 | 1 | 0 | • | 1 | 0 | 0 | 0 |
8.25 | 1 | 0 | 0 | 0 | • | 0 | 1 | 0 | 0 |
11.75 | 1 | 0 | 1 | 1 | • | 1 | 1 | 0 | 0 |
2.875 | 0 | 0 | 1 | 0 | • | 1 | 1 | 1 | 0 |
15.9375 | 1 | 1 | 1 | 1 | • | 1 | 1 | 1 | 1 |
Complete task 1 the Floating Point Representation task sheet
Once we have our decimal number in binary we have to represent it as a floating point number.
Mantissa = 1010 1000
Exponent = 100
The decimal number 6.125 converted to binary is 110.001.
Convert 110.001 to floating point representation. There are 16 bits for mantissa (including the sign bit) and 8 bits for the exponent.
2 marks
Step 1: Move the decimal point before the first 1 and write as floating point number:
Step 2: Write as a floating point number
.110001 x 23
Step 3: Convert 3 (the number of steps the decimal moved) into a binary number.
8 | 4 | 2 | 1 |
---|---|---|---|
0 | 0 | 1 | 1 |
Step 4 : Identify Sign bit.
The sign bit indicates whether a number is positive or negative.
A positive number is represented using a 0
A negative number is represented using a 1
As our number is positive our sign bit is 0.
110 001
0 0000 0000
0011
0
0000
Convert the following binary numbers into floating point representation, assigning 16 bits to the mantissa (including sign bit) and 8 bits for the exponent.
Sign | Mantissa | Exponent | |
---|---|---|---|
1. | 0 | 110 1110 0000 0000 | 0000 0100 |
2. | 0 | 010 1010 1000 0000 | 0000 0101 |
3. | 1 | 101 1011 0000 0000 | 0000 0010 |
4. | 1 | 111 0010 0000 0000 | 0000 0011 |
Complete task 2 & 3 the Floating Point Representation task sheet
Sometimes you might be given a number where you need to move the decimal point to the right instead of the left. For example:
0.0001101011
When you move the decimal point to the right the exponent becomes negative. So our number would be:
.1101011 x 2-3
Convert the following binary number into Floating Point Representation, assigning 16 bits to the Mantissa (incl. sign bit) and 8 bits for the Exponent.
0.0000110101
Step 1: Move the decimal point so it is before the first 1
0.0000110101 = .110101
Convert the following binary number into Floating Point Representation, assigning 16 bits to the Mantissa (incl. sign bit) and 8 bits for the Exponent.
0.0000110101
Step 1: Move the decimal point so it is before the first 1
0.0000110101 = .110101
Step 2: Write as a floating point number
.110101 x 2-4
Convert the following binary number into Floating Point Representation, assigning 16 bits to the Mantissa (incl. sign bit) and 8 bits for the Exponent.
0.0000110101
Step 1: Move the decimal point so it is before the first 1
0.0000110101 = .110101
Step 2: Write as a floating point number
.110101 x 2-4
Step 3: Convert -4 (the number of steps the decimal moved) into a binary number.
-128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
---|---|---|---|---|---|---|---|
1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 |
Step 4 : Identify Sign bit.
The sign bit indicates whether a number is positive or negative.
A positive number is represented using a 0
A negative number is represented using a 1
As our number is positive our sign bit is 0.
Complete task 4 & 5 the Floating Point Representation task sheet
We’ve already seen how numbers are stored in a computer system and that computers can only store numbers as a series of 1s and 0s.
When it comes to storing text a computer works in the exact same way. They store text with its own unique binary number
Unicode is the standard that has been developed for text representation.
We should already know from National 5 about Extended ASCII.
E-ASCII is an 8 bit character set used to store text.
The Extended ASCII system is based on the English alphabet and represents each character using 8 bits (or up to 256 characters).
This is sufficient for 26 upper case letters, 26 lower case letters, a few dozen punctuation characters, the symbols for the digits 0-9, and control characters found in the English language
We should already know from National 5 about Extended ASCII.
E-ASCII is an 8 bit character set used to store text.
The Extended ASCII system is based on the English alphabet and represents each character using 8 bits (or up to 256 characters).
This is sufficient for 26 upper case letters, 26 lower case letters, a few dozen punctuation characters, the symbols for the digits 0-9, and control characters found in the English language
Unfortunately Extended ASCII does not allow us to represent characters from foreign languages for example as we are limited to the 256 characters.
The Unicode system uses at least 16 bits to represent each character (there are now 32 bit Unicode variations as well).
That means we can store and represent 65,356 different characters codes.
The table below compares E-ASCII and Unicode
Extended ASCII | Unicode | |
---|---|---|
Number of bits | 8 | 16 |
Pros | Takes up less storage space as only using 1 byte for each character | Can store and represent 65,356 different characters |
Cons | Can only store and represent 256 characters | Uses twice the storage as Extended ASCII taking up 2 bytes for every character |
Character sets can be represented using either ASCII or Unicode.
Describe an advantage of using Unicode over ASCII, making reference to the number of bits used to represent a character in each format.
2 marks
2018 Q5
Unicode can represent more characters (216) (1 mark) when compared with ASCII (28 or 27) (1 mark)
Bitmapped graphics are a type of graphic that store images as colour code for a two-dimensional grid of pixels.
Pixel is a portmanteau of picture and element which are the dots that make up the graphic
Bit-depth refers to the number of bits that are used as the code for each pixel. In other words how many bits are assigned to each pixel.
Resolution is the number of pixels going across (the width) the image multiplied by the number of pixels going up and down (the height) the image.
Bitmapped graphics are resolution dependent. This means that once the resolution is set once the image is created. Increasing the resolution of the image will cause pixelation.
Dots-per-inch is another type of measure of resolution.
It's useful to know how the file size of a standard and uncompressed bitmap graphic is calculated and it's really easy to understand.
You can use the following formula to calculate it:
Advantages | Disadvantages |
---|---|
Can produce realistic photographic images | Have a large file size (compared to vector graphics) |
Can edit images at pixel level | Resolution is set at point of creation and cannot be increased without a loss of quality (resolution dependent) |
The web page uses bit-mapped graphic files for the book covers.
State one advantage of using bit-mapped graphic files rather than vector graphic files on this web page
1 mark
SQP Q19 (e)
Vector graphics store images as a list of objects, each of which is described by its attributes
Object attributes include: starting (x, y) co-ordinates, line colour, fill colour, line thickness etc.
Vector graphics are resolution independent which means the resolution can be increased without a loss in quality.
Advantages | Disadvantages |
---|---|
Can be scaled without a loss in quality (resolution independent) | Cannot edit at pixel level |
Can make best use of high-resolution output devices | Not suitable if you are looking for photo-realistic images |
Vector objects can be edited independently of each other | |
Can be easily moved/manipulated | |
Smaller files sizes than bitmapped graphics |
Bitmapped graphics | Vector graphics |
---|---|
Larger file sizes | Smaller file sizes |
All pixels are stored | Only objects attributes are stored |
Resolution dependent | Resolution independent |
Overlapping shapes will remove part of the underneath shape | Overlapping shapes don’t affect the underneath shape |
Editable at pixel level | Not editable at pixel level. Only object attributes are editable |
LottoScot has a logo shown below in diagram 1. They want to change the logo to the one in diagram 2.
In diagram 2 the rectangle has been moved forward.
Explain the advantage of making this change using a vector graphic application compared to a bit‑mapped graphic application.
2 marks
2022 Q3
With vector individual objects/attributes can be edited/moved independently or objects can be layered whereas in bitmap you can edit individual pixels
The following are key shortcuts for using DragonSlides and reveal.js.
Key combination | Action |
---|---|
→, PAGE DOWN, SPACE | Next slide |
←, PAGE UP | Previous slide |
SHIFT + → | Last Slide |
SHIFT + ← | First slide |
B | Whiteboard |
W | Widget Board/White Screen |
C | Toggle Notes Canvas |
DEL | Clears Whiteboard/Notes Canvas |
S | Show Presenter Mode |
SHIFT + D | Toggle Dark Mode |
H | Goes to the Home Slide |
META + P | Show Print options window |
In order to use the 'Start Remote' feature, you'll need to download JB Slide Controls from the Apple App Store. Once you have this you'll be able to control the slides using the app from you Apple Watch.
DragonSlides and jamiebalfour.scot are copyright © Jamie B Balfour 2017 - 2024, 2010 - 2024. Content is copyright © Jamie B Balfour