4 hundred quadrillonth?

Luis Zarrabeitia kyrie at uh.cu
Wed May 27 17:24:59 EDT 2009


On Wednesday 27 May 2009 04:26:57 pm Mark Dickinson wrote:
> Luis Zarrabeitia <kyrie at uh.cu> wrote:
> > On Thursday 21 May 2009 08:50:48 pm R. David Murray wrote:
> >> In py3k Eric Smith and Mark Dickinson have implemented Gay's floating
> >> point algorithm for Python so that the shortest repr that will round
> >> trip correctly is what is used as the floating point repr....
> >
> > Little question: what was the goal of such a change? (is there a pep for
> > me to read?) Shouldn't str() do that, and leave repr as is?
>
> It's a good question.  I was prepared to write a PEP if necessary, but
> there was essentially no opposition to this change either in the
> python-dev thread that Ned already mentioned, in the bugs.python.org
> feature request (see http://bugs.python.org/issue1580; set aside
> half-an-hour or so if you want to read this one) or amongst the people
> we spoke to at PyCon 2009, so in the end Eric and I just went ahead
> and merged the changes.  It didn't harm that Guido supported the idea.

Thank you for the reply and the explanation.
After reading the thread, I was sold on the idea. It still feels weird not 
being able to introduce /that quickly/ the idea of float vs real to newbies, 
but now I understand the tradeoff. 

(Now, I'm going to miss showing that to my students who almost inevitably 
complain about the uselessness of the 'floating point representation' chapter 
in the numerical analysis course :D).

> There are still plenty of ways to show what 0.2 really means.  My
>
> favourite is to use the Decimal.from_float method:
> >>> Decimal.from_float(0.2)
>
> Decimal('0.200000000000000011102230246251565404236316680908203125')

Oh, thank you. That was the next thing I was going to ask.

-- 
Luis Zarrabeitia (aka Kyrie)
Fac. de Matemática y Computación, UH.
http://profesores.matcom.uh.cu/~kyrie



More information about the Python-list mailing list