def roundAndStrip(value, dp):
    """
    Round the supplied value to dp decimal places and tidy the end.

    After rounding, strips any trailing zeros after the decimal point,
    and the decimal point itself if that's the last thing we're left with.
    """
    if (dp < 0):
        value = round(value, dp)
        dp = 0
    template = '{{:.{}f}}'.format(dp)
    rv = template.format(value)
    if (dp > 0):
        rv = rv.rstrip('0').rstrip('.')
    return rv