<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def float_to_latex(x, format="%.2g"):
 # pylint: disable=redefined-builtin # pylint: disable=anomalous-backslash-in-string r"""Convert a floating point number to a latex representation. In particular, scientific notation is handled gracefully: e -> 10^ Parameters x : `float` the number to represent format : `str`, optional the output string format Returns ------- tex : `str` a TeX representation of the input Examples -------- '1' '2\times 10^{3}' '10^{2}' r'-5\!\!\times\!\!10^{2}' """

    if x == 0.:
        return '0'
    base_str = format % x
    if "e" not in base_str:
        return base_str
    mantissa, exponent = base_str.split("e")
    if float(mantissa).is_integer():
        mantissa = int(float(mantissa))
    exponent = exponent.lstrip("0+")
    if exponent.startswith('-0'):
        exponent = '-' + exponent[2:]
    if float(mantissa) == 1.0:
        return r"10^{%s}" % exponent
    return r"%s\!\!\times\!\!10^{%s}" % (mantissa, exponent)