from typing import SupportsFloat


def _format_float(value: SupportsFloat, *, decimals: int = 6) -> str:
    """Format a node position into a string.

    This uses the format requested by 2DM: up to nine significant
    digits followed by an exponent, e.g. ``0.5 -> 5.0e-01``.

    :param value: A object that supports casting to :class:`float`.
    :type value: :obj:`typing.SupportsFloat`
    :param decimals: The number of decimal places to include, defaults
        to ``6``.
    :type decimals: :class:`int`, optional
    :return: The formatted string with no extra whitespace.
    :rtype: :class:`str`
    """
    string = f'{" " if float(value) >= 0.0 else ""}{float(value):.{decimals}e}'
    return string