Python: OverflowError: math range error

后端 未结 6 698
轻奢々
轻奢々 2020-12-09 14:56

I get a Overflow error when i try this calculation, but i cant figure out why.

1-math.exp(-4*1000000*-0.0641515994108)
6条回答
  •  离开以前
    2020-12-09 15:36

    To fix it use:

    try:
        ans = math.exp(200000)
    except OverflowError:
        ans = float('inf')
    

提交回复
热议问题