def format_float(x, max_width):
<EOL>whole_width = int(math.log10(abs(x) + <NUM_LIT:1>)) + <NUM_LIT:1><EOL>sign_width = <NUM_LIT:1> if x < <NUM_LIT:0> else <NUM_LIT:0><EOL>decimal_point_width = <NUM_LIT:1> if max_width >= whole_width else <NUM_LIT:0><EOL>return '<STR_LIT>' % (max_width - whole_width - sign_width - decimal_point_width, x)<EOL>
format_float will ensure that a number's decimal part is truncated to
    fit within some bounds, unless the whole part is wider than max_width,
    which is a problem you need to sort out yourself.