In [1]:
from notebook.services.config import ConfigManager
from IPython.paths import locate_profile
cm = ConfigManager(profile_dir=locate_profile(get_ipython().profile))
cm.update('livereveal', {
'theme': 'solarized',
'transition': 'zoom',
'start_slideshow_at': 'selected',
})
Out[1]:
Answer: We don't! To do this, we assign a fixed number of bits for the numerator and a fixed number of bits for the denominator.
I.e.
4 bits for numerators 5 bits for denominator
0101.11101
This works much the same as in denary. We have the representation of the whole number, a decimal point and a representation of the fraction.
8 | 4 | 2 | 1 | . | 1/2 | 1/4 | 1/8 | 1/16 | 1/32 |
---|---|---|---|---|---|---|---|---|---|
1 | 0 | 1 | 0 | . | 1 | 1 | 0 | 0 | 0 |
Note how the decimal side works much the same way as for whole numbers.
What is the decimal representation of this value?
10.75
What could be the issues with this?
This is not a power of 2, so the best we can do is get close.
8 | 4 | 2 | 1 | . | 1/2 | 1/4 | 1/8 | 1/16 | 1/32 |
---|---|---|---|---|---|---|---|---|---|
0 | 1 | 0 | 1 | . | 1 | 1 | 1 | 0 | 1 |
This can cause rounding errors
when storing numbers in Base-2.
0010.0100
0101.1100
When performing operations, you may see that the answer you receive is not the same as the answer you expected. This can happen when you are restricted in the number of bits where the answer has more bits than the numbers you are performing an operation on.
This is called overflow
and the answer to this is simple:
DISCARD ALL THE OVERFLOW BITS!
Problem solved, but you can see why computers mess up sometimes.
In [ ]:
http://www.bbc.co.uk/skillswise/factsheet/ma12pape-l1-f-long-division
https://www.mathsisfun.com/long_division.html
Look at the binary division pdf in the zip and follow the steps.
Note: Division involving negative numbers is easiest to do by converting to positives and adjusting the sign.
There is an exercise coming.
These are called bitwise operators and they work by performing operations on the binary representations of the values.
You get the result back in decimal, so these steps are followed:
Let's try each operator:
Then we want to send as few bytes as possible. In embedded computers, sensors and other IoT devices, we use flags
to relate to configuration, write drivers or as instructions for microcontrollers.
I.e. a bit relates to an individual setting.
1101 - sensor on, led on, power save off, Bluetooth connection on 1001 - sensor on, led off, power save off, Bluetooth connection on
There is another use that you see every day: