On 04/09/2008, at 8:22 PM, agi wrote:

>
> Hi,
> I want to check if a number is set to infinity or NaN. So I tried this
> if-statement:
>
> if x!=infinity:
>    print x
>
> But this doesn't work when x=a/b with a very small b, so that x
> becomes infinity.
> (I'm using SAGE Version 3.0.1)

If x = 1.0/0 and y = -1.0/0, then
(1) x.is_infinity() and y.is_infinity() are both True
(2) x == y is False.
(3) x.is_NaN() is False.

Have a look at
http://sagemath.org/doc/ref/module-sage.rings.real-double.html
(search for "is_infinity") (There may be a better reference.)

D



--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to