Why is this division not performed correctly?

前端 未结 3 1817

I\'ve a strange issue in Python: the division is not performed correctly:

print pointB[1]
print pointA[1]
print pointB[0]
print pointA[0]
print  (pointB[1]-         


        
3条回答
  •  鱼传尺愫
    2020-12-06 19:37

    This is how integer division works in python. Either use floats or convert to float in your calculation:

    float(pointB[1]-pointA[1]) / (pointB[0]-pointA[0])
    

提交回复
热议问题