Python fails on math
Westley Martínez
anikom15 at gmail.com
Thu Feb 24 20:16:49 EST 2011
On Fri, 2011-02-25 at 00:57 +0000, Grant Edwards wrote:
> On 2011-02-25, Westley Mart?nez <anikom15 at gmail.com> wrote:
>
> > Maybe I'm wrong, but wouldn't compiling Python with a compiler that
> > supports extended precision for intermediates allow Python to use
> > extended precision for its immediates?
>
> I'm not sure what you mean by "immediates", but I don't think so. For
> the C compiler to do an optimization like we're talking about, you
> have to give it the entire expression in C for it to compile. From
> the POV of the C compiler, C-Python never does more than one FP
> operation at a time when evaluating Python bytecode, and there aren't
> any intemediate values to store.
>
> > Or does Python use its own floating-point math?
>
> No, but the C compiler has no way of knowing what the Python
> expression is.
>
> --
> Grant
>
>
>
I meant to say intermediate. I think I understand what you're saying.
Regardless, the point is the same; floating-point numbers are different
from real numbers and their limitations have to be taken into account
when operating on them.
More information about the Python-list
mailing list