Python fails on math
anikom15 at gmail.com
Fri Feb 25 02:16:49 CET 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.
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