def fix(x, digs):
if type(x) != type('<STR_LIT>'): x = repr(x)<EOL>try:<EOL><INDENT>sign, intpart, fraction, expo = extract(x)<EOL><DEDENT>except NotANumber:<EOL><INDENT>return x<EOL><DEDENT>intpart, fraction = unexpo(intpart, fraction, expo)<EOL>intpart, fraction = roundfrac(intpart, fraction, digs)<EOL>while intpart and intpart[<NUM_LIT:0>] == '<STR_LIT:0>': intpart = intpart[<NUM_LIT:1>:]<EOL>if intpart == '<STR_LIT>': intpart = '<STR_LIT:0>'<EOL>if digs > <NUM_LIT:0>: return sign + intpart + '<STR_LIT:.>' + fraction<EOL>else: return sign + intpart<EOL>
Format x as [-]ddd.ddd with 'digs' digits after the point
    and at least one digit before.
    If digs <= 0, the point is suppressed.