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

Chris Angelico rosuav at gmail.com
Fri Jul 12 17:23:28 CEST 2013


On Sat, Jul 13, 2013 at 1:16 AM, Gerald Britton
<gerald.britton at gmail.com> wrote:
> "Considering that Python can't represent π in a float anyway, I
>
> wouldn't be too bothered. "
>
>>>> import math
>>>> type(math.pi)
> <class 'float'>

That's an approximation to pi, which is a standard floating-point
value. It's simply 3.141592653589793, nothing more nor less. Infinity
is a special floating-point value that actually represents the concept
of infinity, not just some huge number. Hence, infinity is special, pi
is not. IEEE floating point cannot represent pi, the square root of 2,
or i, but it can represent infinity and nan, so there need to be ways
to create those.

ChrisA


More information about the Python-ideas mailing list