def writeFunkyFloat(f, width=11, significant_digits=None):
    """
    Write one of Red's Funky Floats...

    Anatomy of a funky float:

    Consider the number 3124.5611 written to a field with width=10
        ' 3.12456+3'
        '_X.XXXXX+E'
    where '_' is either a space (' ') or a minus sign ('-'),
    'X.XXXXX' is the number itself, in exponential notation, with exponent 'E'.
    The floating point 'E' is dropped, saving a character.
    """
    if f is None:
        return width * ' '

    # compute the number of sig figs the user "really" wants
    if significant_digits is None or significant_digits > width - 1:
        significant_digits = width - 1

    # leave an extra space for leading minus sign if needed
    if f < 0.0:
        significant_digits -= 1

    # compute the possible output formats
    g_frmt = '%' + str(width) + '.' + str(significant_digits) + 'g'
    e_frmt = '%' + str(width) + '.' + str(significant_digits - 4) + 'e'

    # try with the 'g' format, we may get lucky
    s = g_frmt % round(f, significant_digits)

    # OK, number too big, so must use explicit exponential notation, but with E-less representation
    if 'e' in s or len(s) > width:
        s = e_frmt % round(f, significant_digits)
        s = s.replace('e', '')

    # Check to make sure the number isn't too long
    if len(s) > width:
        raise ValueError('number too big, len("%s")=%i<%i' % (s, len(s), width))
    return s.strip().ljust(width)