12 lines
226 B
Python
12 lines
226 B
Python
# sign function
|
|
def sgn(x):
|
|
if x>=0:
|
|
return 1
|
|
return -1
|
|
|
|
# check whether a number is an integer (with tolerance)
|
|
def isint_nonzero(x):
|
|
if abs(x)<1e-11:
|
|
return False
|
|
return abs(round(x)-x)<1e-11
|