def format_complex_number(real: float, imag: float) -> str:
    """Get a string to display a given complex number nicely"""
    str_imag = (
        "" if imag == 0 else ("" if abs(imag) == 1 else str(round(abs(imag), 3))) + "i"
    )
    str_real = "" if real == 0 else str(round(real, 3))
    sign = "0" if real == 0 and imag == 0 else " + " if real * imag != 0 else ""
    # if both are defined, move imag's sign to sign.
    if imag < 0:
        sign = " - "

    return "{}{}{}".format(str_real, sign, str_imag)