from math import floor, log10


def _round_sig(x, sig=3):
    """
    Rounds x to sig significant digits
    :param x: The value to round
    :param sig: Number of significant digits
    :return: rounded value
    """
    # Check for zero to avoid math value error with log10(0.0)
    if abs(x) < 1e-12:
        return 0
    else:
        return round(x, sig-int(floor(log10(abs(x))))-1)