def string_to_number(byte_repr_str):
    """
    Args:
        byte_repr_str (str): e.g. 100MB, 10Kb; float is not allowed
    Returns:
        num (int): bytes
    """
    is_parsing_unit = False
    num = 0
    for ch in byte_repr_str:
        if ch.isdigit():
            assert is_parsing_unit is False
            num = num * 10 + int(ch)
            continue
        else:
            is_parsing_unit = True

        if ch.lower() == 'k':
            num = num * 1024
        elif ch.lower() == 'm':
            num = num * 1024 * 1024
        elif ch.lower() == 'g':
            num = num * 1024 * 1024 * 1024
        elif ch == 'B':
            num = num * 8
        elif ch == 'b':
            num = num * 1
        else:
            # invalid format
            assert(False)
    return num