Is it possible to set a number to NaN or infinity?

后端 未结 4 2145
无人及你
无人及你 2020-12-22 16:46

Is it possible to set an element of an array to NaN in Python?

Additionally, is it possible to set a variable to +/- infinity? If so, is there any funct

4条回答
  •  青春惊慌失措
    2020-12-22 17:23

    When using Python 2.4, try

    inf = float("9e999")
    nan = inf - inf
    

    I am facing the issue when I was porting the simplejson to an embedded device which running the Python 2.4, float("9e999") fixed it. Don't use inf = 9e999, you need convert it from string. -inf gives the -Infinity.

提交回复
热议问题