def epsilon(dtype):
  """A simple way to determine (at runtime) the precision of a given type
  real number.
  Precision is defined such that (1.0 + epsilon(dtype) > 1.0).
  Below this number, the addition will not yield a different result.
  """
  one = dtype(1.0)
  small = one
  small2 = small
  while one + small > one:
    small2 = small
    small = dtype(small / 2)
  return small2