Hi all, I downloaded Python-2.5.2.tar.bz2 and want to lean some math function implementation in it. I found that mathmodule.c implements 'math' module of python. In this file there's a function loghelper()(in Python-2.5.2/Modules/mathmodule.c), it seems with this function's help any base logarithm can be computed, its comments state as:
/* A decent logarithm is easy to compute even for huge longs, but libm can't do that by itself -- loghelper can. func is log or log10, and name is "log" or "log10". Note that overflow isn't possible: a long can contain no more than INT_MAX * SHIFT bits, so has value certainly less than 2**(2**64 * 2**16) == 2**2**80, and log2 of that is 2**80, which is small enough to fit in an IEEE single. log and log10 are even smaller. */ static PyObject* loghelper(PyObject* args, double (*func)(double), char *format, PyObject *arg) { ...... } I cannot understand it well, can anyone explain me why and how loghelper() can compute any base logarithm? Or could anyone give me some reference(such as, books or papers)? Thanks in advance, -Rockins Chen -- http://mail.python.org/mailman/listinfo/python-list