[issue15438] Incredible issue in math.pow

Amaury Forgeot d'Arc report at bugs.python.org
Thu Jul 26 18:48:36 CEST 2012


Amaury Forgeot d'Arc <amauryfa at gmail.com> added the comment:

C comparison rules are different from Python's.
In the program below (which outputs 1), the mixed comparison will first convert the literal to a double, and lost some precision.
Python does the opposite: the (imprecise) float is converted to a long, so all digits are compared.


#include <math.h>
#include <stdio.h>
int main()
{
    printf("result: %d\n", (pow(43,10) == 21611482313284249));
}

----------
nosy: +amaury.forgeotdarc

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15438>
_______________________________________


More information about the Python-bugs-list mailing list