from typing import Union


def _get_tol_from_less_precise(check_less_precise: Union[bool, int]) -> float:
    """
    Return the tolerance equivalent to the deprecated `check_less_precise`
    parameter.

    Parameters
    ----------
    check_less_precise : bool or int

    Returns
    -------
    float
        Tolerance to be used as relative/absolute tolerance.

    Examples
    --------
    >>> # Using check_less_precise as a bool:
    >>> _get_tol_from_less_precise(False)
    0.5e-5
    >>> _get_tol_from_less_precise(True)
    0.5e-3
    >>> # Using check_less_precise as an int representing the decimal
    >>> # tolerance intended:
    >>> _get_tol_from_less_precise(2)
    0.5e-2
    >>> _get_tol_from_less_precise(8)
    0.5e-8

    """
    if isinstance(check_less_precise, bool):
        if check_less_precise:
            # 3-digit tolerance
            return 0.5e-3
        else:
            # 5-digit tolerance
            return 0.5e-5
    else:
        # Equivalent to setting checking_less_precise=<decimals>
        return 0.5 * 10 ** -check_less_precise