def METHOD_NAME(self, val, floatdecimal=0) -> str:
    """
    Format a single numerical value into a string
    with the appropriate number of decimal.
    """
    sval = str(val)
    if sval.lstrip('-').lstrip('+').isdigit() and floatdecimal == 0:
        return sval
    try:
        fval = float(val)
    except Exception:
        return sval
    if fval == 0 or (abs(fval) > 1e-3 and abs(fval) < 1e4):
        form = 'f'
        addlen = 5
    else:
        form = 'e'
        addlen = 8
    ndec = max(len(str(fval-int(fval)))-2, floatdecimal)
    if floatdecimal > 16:
        ndec = max(floatdecimal,ndec)
    else:
        ndec = min(ndec, 10)
    sval = '{v:>{l}.{p}{f}}'.format(v=fval, l=ndec+addlen, p=ndec, f=form)
    sval = sval.replace('e', 'd')
    return sval