Rappresenting infinite

Robert Kern robert.kern at gmail.com
Fri Jun 29 10:08:20 EDT 2007


mmanns at gmx.net wrote:
> On Thu, 28 Jun 2007 23:20:30 -0500
> Robert Kern <robert.kern at gmail.com> wrote:
> 
>> mmanns at gmx.net wrote:
>>> Does it differ from the
>>> built-in inf?
>> What built-in inf?
> 
> $ python
> Python 2.4.4 (#2, Apr  5 2007, 20:11:18)
> [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> a = 1.0e1000
>>>> b = 2.0e1000
>>>> a
> inf
>>>> b
> inf
>>>> a == b
> True
>>>> type(a)
> <type 'float'>

Okay, I thought you meant that there was an actual symbol 'inf' in the builtins
or in a module somewhere.

>> No. You can make one that fits your requirements, though.
> 
> I am struggling to oversee the implications of design choices for inf
> behaviour - especially if it comes to comparison with float type inf.
> The type in my application contains a gmpy.mpq and a float that is
> always kept between -1 and 1 by adding to the mpq on each operation.
> I am looking for a robust inf design for this type. (Note: mpq and
> float inf do not compare).

You probably won't find one. You'll have to write it yourself.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco




More information about the Python-list mailing list