def strf3(val):
    """Nicely formats a float (single precision), remove trailing zeros """
    if val == 0.0:
        return '0.0'
    if abs(val) > 1.0:
        strg = '{0:.3f}'.format(val)
    elif abs(val) > 0.01:
        strg = '{0:.6f}'.format(val)
    else:
        return '{0:.7e}'.format(val)
    if strg[-3:] == '000':
        return strg[:-3]
    if strg[-2:] == '00':
        return strg[:-2]
    return strg
