This will probably be closed for being a duplicate, but just so one can see how this plays out:
>>> import math
>>> math.log(8)
2.0794415416798357
>>> math.log(2)
0.6931471805599453
Now let's say you need to compute math.log(8) % math.log(2)
. You need to compute the remainder after dividing math.log(2)
into math.log(8)
. Let's see, does it go in 3 times?
0.6931471805599453
+ 0.6931471805599453
+ 0.6931471805599453
--------------------
2.0794415416798359
Woah! We overshot the value of 2.0794415416798357 which means it actually goes in TWO times:
0.6931471805599453
+ 0.6931471805599453
--------------------
1.3862943611198906
Okay so what is the remainder?
2.0794415416798359
- 1.3862943611198906
--------------------
0.6931471805599453
So TL;DR your remainder is close to math.log(2)
because of rounding errors. It does not go in exactly three times. It goes in two times with just about math.log(2)
left over.
Yes when you print the quotient it says 3.0
but again, this is all rounding error in floating point, which is not unique to Python.