round to a "scientific notation" tuple of (factor, exponent)
    such that 1 < factor < 1000, and factor * 10 ** exponent == val

def si_round(val):
    '''
    round to a "scientific notation" tuple of (factor, exponent)
    such that 1 < factor < 1000, and factor * 10 ** exponent == val
    '''
    if val < 0:
        neg = True
        val = -val
    elif val == 0:
        return 0, 0
    else:
        neg = False
    exp = math.log(val) / math.log(1000)
    if exp < 0:
        exp = int(exp) - 1
    else:
        exp = int(exp)
    val = val / 1000.0 ** exp
    if neg:
        val = -val
    return val, 3 * exp