import math


def roundoff(a, digit=2):
    """
    roundoff the number with specified digits.

    :param a: float
    :param digit:
    :return:

    :Examples:
    >>> roundoff(3.44e10, digit=2)
     3.4e10
    >>> roundoff(3.49e-10, digit=2)
     3.5e-10
    """
    if a > 1:
        return round(a, -int(math.log10(a)) + digit - 1)
    else:
        return round(a, -int(math.log10(a)) + digit)