What is the range of values a float can have in Python?

前端 未结 6 1965
我在风中等你
我在风中等你 2020-11-29 03:43

What are its smallest and biggest values in python?

6条回答
  •  孤独总比滥情好
    2020-11-29 04:31

    Technically speaking, the smallest float is -inf and the max float inf:

    >>> (float('-inf')            #   negative infinity 
    < -1.7976931348623157e+308    #*  smallest float that is not negative infinity 
    < -4.9406564584124654e-324    #*  biggest negative float that is not zero
    < 0                           #   zero duh
    < 4.9406564584124654e-324     #*  smallest positive float that is not zero
    < 1.7976931348623157e+308     #*  biggest float that is not positive infinity
    < float('inf'))               #   positive infinity
    True
    

    numbers with * are machine-dependent and implementation-dependent.

提交回复
热议问题