University of Plymouth - Stages 1, 2 and 3 / Mbed OS Task352Solution

Fork of Task352Solution by Nicholas Outram

Committer:
noutram
Date:
Tue Oct 02 07:33:59 2018 +0000
Revision:
2:82201f763676
Added solutions to questions in notes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
noutram 2:82201f763676 1 Answer to questions
noutram 2:82201f763676 2
noutram 2:82201f763676 3 Q1. 1 second
noutram 2:82201f763676 4 Q2. XOR
noutram 2:82201f763676 5 Q3. D3
noutram 2:82201f763676 6
noutram 2:82201f763676 7 Q4. This project is one possible solution
noutram 2:82201f763676 8
noutram 2:82201f763676 9 The key line is this
noutram 2:82201f763676 10
noutram 2:82201f763676 11 unsigned int binaryInput = SW1 + (SW2 << 1);
noutram 2:82201f763676 12
noutram 2:82201f763676 13 where SW1 and SW2 are the switches for the least and most significant bits respectively.
noutram 2:82201f763676 14
noutram 2:82201f763676 15 Note the use of << to multiply by 2. A left shift is a cheap operation in computing terms (does not require many CPU cycles).