How to distinguish different types of NaN float in Python

后端 未结 4 1219
悲&欢浪女
悲&欢浪女 2021-02-13 22:27

I\'m writing Python 2.6 code that interfaces with NI TestStand 4.2 via COM in Windows. I want to make a \"NAN\" value for a variable, but if I pass it float(\'nan\')

4条回答
  •  借酒劲吻你
    2021-02-13 23:26

    John Cook had a nice post on this that might be helpful:

    • IEEE floating point arithmetic in Python

    Update: won't this work?

    In [144]: import scipy
    
    In [145]: scipy.nan
    Out[145]: 1.#QNAN
    
    In [146]: scipy.inf
    Out[146]: 1.#INF
    
    In [147]: scipy.inf * 0
    Out[147]: -1.#IND
    

提交回复
热议问题