The results differ because of the limited precision of the floating-point type and because of the way the subtraction operator arranges its operands of the same type. The gamma function returns a float, so it cannot return an exact answer for numbers larger. This page gives a good description of the problems.
In gamma(101)-fac(100) term fac(100) converted to a float before the subtraction operation.
>>> gamma(101) 9.332621544394415e+157 >>> float(fac(100)) 9.332621544394415e+157
The most significant part of fac(100) , which corresponds to the float, corresponds to the value of gamma(101) , therefore, subtraction leads to 0.0 .
For your second test, gamma(101) has no fraction, so math.floor has no effect:
>>> math.floor(gamma(101)) == gamma(101) True
When you convert gamma(101) to long, you can clearly see that this is inaccurate:
>>> long(gamma(101)) 933262154439441509656467047959538825784009703731840988 310128895405822272385704312950661130892883272778258496 64006524270554535976289719382852181865895959724032L >>> fac(100) 933262154439441526816992388562667004907159682643816214 685929638952175999932299156089414639761565182862536979 20827223758251185210916864000000000000000000000000L
source share