Tuesday, 3 February 2015

Performing calculations, counting in binary and the Fibonacci sequence

1) The formula used to return a whole number when doing division is " % " 

2) The remainder of a division can be discovered using the operator %:
>>> 26%7
5
3) In computing it is important to understand number systems and in particular binary, because it is very useful and simple for us humans who are used to working in base 10.

4) The binary system works like this 
01001010
155 can be subtracted by 128, producing 27:
155 - 128 = 27
1286432168421
1
Our new number, 27, can’t be subtracted by either 64 or 32. Both of those positions get a 0. We can subtract by 16, producing 11.
27 - 16 = 11
1286432168421
1001
And 8 subtracts from 11, producing 3. After that, no such luck with 4.
11 - 8 = 3
1286432168421
100110
Our 3 can be subtracted by 2, producing 1. And finally, the 1 subtracts by 1 to make 0.
3 - 2 = 1
1 - 1 = 0
1286432168421
10011011

5)                  

No comments:

Post a Comment