def _decimal_to_ratio(d):
    """Convert Decimal d to exact integer ratio (numerator, denominator).

    >>> from decimal import Decimal
    >>> _decimal_to_ratio(Decimal("2.6"))
    (26, 10)

    """
    sign, digits, exp = d.as_tuple()
    if exp in ('F', 'n', 'N'):
        assert not d.is_finite()
        raise ValueError
    num = 0
    for digit in digits:
        num = num * 10 + digit
    if exp < 0:
        den = 10 ** -exp
    else:
        num *= 10 ** exp
        den = 1
    if sign:
        num = -num
    return num, den
