How can I represent an infinite number in python? No matter which number you enter in the program, no number should be greater than this representation of infinity.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In Python, you can do:
In Python 3.5, you can do:
And then:
Will always be true. Unless of course, as pointed out, x is also infinity or “nan” (“not a number”).
Additionally (Python 2.x ONLY), in a comparison to
Ellipsis,float(inf)is lesser, e.g:would return true.