A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/python/python_cmath_isinf_function.htm below:

Python cmath.isinf() Function

Python cmath.isinf() Function

The Python cmath.isinf() function checks whether a given value is positive or negative infinite.

This function returns True if the specified number is infinite, otherwise it returns False.

For instance, if we have a floating point number "x = float('inf')", which represents positive infinity, i.e "True".

Syntax

Following is the basic syntax of the Python cmath.isinf() function −

cmath.isinf(x)
Parameters

This function accepts a numeric value as a parameter. Represents the floating point number to be infinity.

Return Value

This method returns a boolean value, i.e., True or False.

Example 1

In the below example, we are rectifying if positive infinity is infinite using cmath.isinf() function −

import cmath
x = cmath.isinf(float('inf'))
print(x)
Output

The output obtained is as follows −

True
Example 2

Here, we are checking if negative infinity is infinite using the cmath.isinf() function −

import cmath
res = cmath.isinf(float('-inf'))
print(res)
Output

Following is the output of the above code −

True
Example 3

Now, we are checking if "100" is infinite using cmath.isinf function −

import cmath
result = cmath.isinf(float(100))
print("The result is:",result)
Output

We will get the output as shown below −

The result is: False
Example 4

In this example, we are checking if NaN(Not a Number) is infinite using the cmath.isinf() function −

import cmath
result = cmath.isinf(float('NaN'))
print(result)
Output

The result is obtained as follows −

False

python_modules.htm


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4