def asUnit(data, unit, precision):
    """
Convert to rich-string with a certain unit and precision. The output is e.g. ``"1.1d"``.

:arguments:

  **data** (``<int>`` | ``<float>``)
    Numerical value (e.g. ``1.1``).

  **unit** (``<str>``)
    The unit (e.g. ``"d"``).

  **precision** (``<int>``)
    The precision with which to print (e.g. ``1``).

:returns:

  ``<str>``
    The rich-string.
  """
    if precision:
        return '{{0:.{precision:d}f}}{{1:s}}'.format(precision=precision
            ).format(data, unit)
    if abs(round(data)) < 10.0:
        return '{0:.1f}{1:s}'.format(data, unit)
    else:
        return '{0:.0f}{1:s}'.format(round(data), unit)
