For example:
def get_epsilon(dtype):
eps = dtype(1)
while dtype(1) + dtype(eps) != dtype(1):
previous_eps = eps
eps = dtype(eps) / dtype(2)
return previous_eps
print(int, get_epsilon(int))
print(float, get_epsilon(float))
import numpy as np
print(np.float128, get_epsilon(np.float128))
Gives, on my system:
<class 'int'> 1
<class 'float'> 2.220446049250313e-16
<class 'numpy.float128'> 1.08420217249e-19