+/-infinity in Python?

A

Andreas Neudecker

Hi.

Is there anything like +infinity and -infinity available in Python, and
can it be used in comparisons together with int or float numbers?

Regards


Andreas
 
P

Peter Otten

Andreas said:
Is there anything like +infinity and -infinity available in Python, and
can it be used in comparisons together with int or float numbers?

To lazy to look it up, so let's try:

:)

Peter
 
M

Magnus Lie Hetland

To lazy to look it up, so let's try:
[snip]

Looking it up might be good, though... See, for example, PEP 754,
"IEEE 754 Floating Point Special Values":

http://www.python.org/peps/pep-0754.html

The problem is that the expression float('infinity') works on some
platforms, along with float('Inf'), but, as the PEP points out, on
many systems you'll just get an error. You could also try stuff like
float(1e3000).

So, my response to the original question would be "sort of" -- since
it's there, but it's not particularly reliable. Let's just hope that
PEP 754 (or something similar) is accepted; infinity _is_ certainly
useful...
 
A

Alexander Schmolck

Andreas Neudecker said:
Hi.

Is there anything like +infinity and -infinity available in Python, and can it
be used in comparisons together with int or float numbers?

The newest version of numarray and scipy should offer the functionality you
want (at least for supported platforms).

'as
 
A

Andreas Neudecker

Hello Peter, Magnus,

thanks for your hints.

I will read the PEPs first, because I need compatibility at least for
Linux and Windows ...

Kind regards


Andreas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top