Re: Rappresenting infinite

2007-07-02 Thread John Nagle
Robert Kern wrote: > [EMAIL PROTECTED] wrote: > > >>float('inf') works well, no? > It is not cross-platform. The parsing of strings into floats and the string > representation of floats is dependent on your system's C library. For these > special values, this differs across platforms. Your code

Re: Rappresenting infinite

2007-07-02 Thread Robert Kern
[EMAIL PROTECTED] wrote: > float('inf') works well, no? > >>>> inf = float('inf') >>>> inf / inf >nan >>>> -inf >-inf >>>> inf / 0 >ZeroDivisionError: float division >>>> 1 / inf >0.0 >>>> 0 * float('inf') >nan It is not cross-platform. The parsing of

Re: Rappresenting infinite

2007-07-02 Thread [EMAIL PROTECTED]
On Jun 27, 6:41 am, andrea <[EMAIL PROTECTED]> wrote: > I would like to have a useful rappresentation of infinite, is there > already something?? > > I was thinking to something like this > > class Inf(int): > """numero infinito""" > def __init__(self,negative=False): >

Re: Rappresenting infinite

2007-07-02 Thread andrea
Mm very interesting thread, for my needs from numpy import inf is more than enough :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Rappresenting infinite

2007-06-29 Thread Facundo Batista
[EMAIL PROTECTED] wrote: >> 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

Re: Rappresenting infinite

2007-06-29 Thread Terry Reedy
"John Nagle" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] |If Python numerics don't define | +INF, -INF, and NaN, along with the tests for them, that's a | flaw in the language. Are you volunteering to fix the 'flaw'? CPython floating point numerics are currently defined to

Re: Rappresenting infinite

2007-06-29 Thread John Nagle
Robert Kern wrote: > [EMAIL PROTECTED] wrote: > >>On Thu, 28 Jun 2007 23:20:30 -0500 >>Robert Kern <[EMAIL PROTECTED]> wrote: >> >> >>>[EMAIL PROTECTED] 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) >>[GC

Re: Rappresenting infinite

2007-06-29 Thread Robert Kern
[EMAIL PROTECTED] wrote: > On Thu, 28 Jun 2007 23:20:30 -0500 > Robert Kern <[EMAIL PROTECTED]> wrote: > >> [EMAIL PROTECTED] 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) (Debi

Re: Rappresenting infinite

2007-06-28 Thread mmanns
On Thu, 28 Jun 2007 23:20:30 -0500 Robert Kern <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] 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", "

Re: Rappresenting infinite

2007-06-28 Thread Robert Kern
[EMAIL PROTECTED] wrote: > On Wed, 27 Jun 2007 11:59:29 - > Rob De Almeida <[EMAIL PROTECTED]> wrote: > >> On Jun 27, 6:41 am, andrea <[EMAIL PROTECTED]> wrote: >>> I would like to have a useful rappresentation of infinite, is there >>> already something?? >> from numpy import inf > > $ pytho

Re: Rappresenting infinite

2007-06-28 Thread mmanns
On Wed, 27 Jun 2007 11:59:29 - Rob De Almeida <[EMAIL PROTECTED]> wrote: > On Jun 27, 6:41 am, andrea <[EMAIL PROTECTED]> wrote: > > I would like to have a useful rappresentation of infinite, is there > > already something?? > > from numpy import inf > $ python Python 2.4.4 (#2, Apr 5 2007

Re: Rappresenting infinite

2007-06-27 Thread Rob De Almeida
On Jun 27, 6:41 am, andrea <[EMAIL PROTECTED]> wrote: > I would like to have a useful rappresentation of infinite, is there > already something?? from numpy import inf -- http://mail.python.org/mailman/listinfo/python-list

Rappresenting infinite

2007-06-27 Thread andrea
I would like to have a useful rappresentation of infinite, is there already something?? I was thinking to something like this class Inf(int): """numero infinito""" def __init__(self,negative=False): self.negative = negative def __cmp__(self,y):