Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python math.isinf() Method

Python math.isinf() Method

Python math Module Python math Module

Python math.isinf() The method determines whether x is infinite, returning True if x is positive or negative infinity, otherwise False.

Python version: 2.6

Syntax

The syntax of the math.isinf() method is as follows:

math.isinf(x)

Parameter Description:

Return Value

Returns a Boolean; True if x is positive or negative infinity, otherwise False.

Example

The following example checks whether numbers are infinite:

Example

Import the math package

import

math

Check whether a number is infinite

print

(

math

.

isinf

(

56

)

)

print

(

math

.

isinf

(

45.34

)

)

print

(

math

.

isinf

(

45.34

)

)

print

(

math

.

isinf

(

math

.

inf

)

)

print

(

math

.

isinf

(

float

(

"nan"

)

)

)

print

(

math

.

isinf

(

float

(

"inf"

)

)

)

print

(

math

.

isinf

(

float

(

"-inf"

)

)

)

print

(

math

.

isinf

(

math

.

inf

)

)

Output result:



False

False

False

True

False

True

True

True

Python math Module Python math Module