Python Tutorial Python Advanced Python References Python Libraries

Python cmath - nanj



The Python cmath.nanj is used to return a complex number with zero real part and NaN imaginary part. It is equivalent to the output of complex(0.0, float('nan')).

Syntax

#New in version 3.6
cmath.nanj

Parameters

No parameter is required.

Return Value

Returns a complex number with zero real part and NaN imaginary part.

Example:

The example below shows the usage of cmath.nanj.

import cmath

#print complex(0.0, float('nan'))
print(cmath.nanj)

#print -complex(0.0, float('nan'))
print(-cmath.nanj)

The output of the above code will be:

nanj
(-0+nanj)

❮ Python cMath Module