2013-07-12 47 views

回答

9

您可以使用absolute value

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

因为x-1绝对值x1,同样之间的距离variable-1绝对值variable1之间的距离。