import math


def GetPrintPrecision(tolerance):
  """Returns int, number of decimals to display in a format string.
  
  tolerance - float target difference between 2 values
  {0:10.{precision}f}.format(10.0, precision=printPrecision(tolerance))
  """
  if tolerance >= 0:
    return 0
  # Log10 will be negative because tolerance with be below 0
  width = math.log10(tolerance)
  return math.ceil(-width)