Infinity and infinitesimal in python

            In doing a matlab script into the python code, matlab infinity can be directly used infto represent, may be infinitesimal -inf, but can not be used directly in Python, you need to use float("inf"), summary records about

  minDiff = INF
  minDiff = inf

     

Error message: unresolved reference INF, unresolved reference inf

Corrected to

minDiff = float("inf")

      No error message, normal execution

Simple example

minDiff = float("inf")
a = 200000
if a<minDiff:
    print("yes")

Output

yes

     

     

minDiff = float("-inf")
a = -200000
if a>minDiff:
    print("yes")

Output

yes

Guess you like

Origin blog.csdn.net/qq_43657442/article/details/109291955