[Tutor] infinity
Alan Gauld
alan.gauld at yahoo.co.uk
Sat May 22 06:38:57 EDT 2021
On 22/05/2021 10:51, Manprit Singh wrote:
> Just need to know if it is valid to use float("inf") for infinity and
> -float("inf") for negative infinity in python ?
Yes it is valid, that's why it's in the language.
Whether it is wise, depends in what you are trying to do.
Mostly it does what you expect but some operations
will return nan so you need to handle that in addition
to inf itself.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list