[Python-ideas] float('∞')=float('inf')

Laurens Van Houtven _ at lvh.io
Fri Jul 12 17:13:50 CEST 2013


I was speaking generally about numbers; it's certainly true that any
floating point implementation with a limited mantissa and exponent has some
upper limit as to which integer it can store exactly; and at some point
above that it's going to have to either throw an error, give you a smaller
number, or give you infinity ;)


On Fri, Jul 12, 2013 at 5:02 PM, Joshua Landau <joshua at landau.ws> wrote:

> On 12 July 2013 15:46, Laurens Van Houtven <_ at lvh.io> wrote:
> > On Fri, Jul 12, 2013 at 4:43 PM, Gerald Britton <
> gerald.britton at gmail.com>
> > wrote:
> >>
> >> Man I don't know how you are doing this!  I just tried:
> >>
> >> float('<greek letter pi>') and got
> >>
> >> Value error: could not convert string to float '<greek letter pi>'
> >>
> >> For that matter, I can't figure out how to type the greek letter for
> >> pi in gmail!  Guess I have some things to learn.
> >>
> >> So, if Python doesn't recognize the symbol for pi, why should it
> >> recognize the one for infinity?
> >
> >
> > The example he posted is of digits, not of any particular symbol for a
> > constant. The difference, obviously, is that you can't write infinity as
> a
> > bunch of digits, whereas you can at least approximate pi with any number
> of
> > digits.
>
> Ahem:
>
> >>> float("1"*310)
> inf
>
> Just because.
>
> My personal reason for thinking that unicode infinity is reasonable
> whereas unicode pi/tau/phi/etc. is not, is simply that we *already*
> special-case infinity. We do not do so for other mathematical
> constants. Additionally, Pi only holds the value of half the circle
> constant by default -- other branches of mathematics uses for other
> things and some use it as a variable. They are rare, granted, but Pi
> is not as clear cut as, say, "9" or "infinity".
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130712/7de63956/attachment.html>


More information about the Python-ideas mailing list