2013-07-12 42 views

回答

9

您可以使用absolute value

if abs(x-1) < abs(variable-1): 
    ... 

因爲x-1絕對值x1,同樣之間的距離variable-1絕對值variable1之間的距離。