import math


def _toexponent(number):
    """
    Formats exponent to PENELOPE format (E22.15)

    Args:
        number (Float): Number to format

    Returns:
        str: number to PENELOPE format (E22.15)
    """
    if number == 0.0:
        exponent = 0
    else:
        exponent = int(math.log10(abs(number)))

    if exponent >= 0:
        exponent_str = "+{:2d}".format(abs(exponent))
    else:
        exponent_str = "-{:2d}".format(abs(exponent))

    exponent_str = exponent_str.replace(" ", "0")  # Replace white space in the exponent

    coefficient = float(abs(number)) / 10 ** exponent

    if number >= 0:
        number_str = "+{0:17.15f}E{1}".format(coefficient, exponent_str)
    else:
        number_str = "-{0:17.15f}E{1}".format(coefficient, exponent_str)

    # The number should not be longer than 22 characters
    assert len(number_str) == 22

    return number_str