import re


def parseval(val):
    """Parse a value that could be int, float, % or contain a memory unit."""
    if val == "-":
        return None
    if re.match("\d+$", val):
        return int(val)
    if re.match("\d+(.\d+)?([eE][+-]\d+)?$", val):
        return float(val)
    if re.match("\d+(.\d+)?%$", val):
        return 100 * float(val[:-1])
    if re.match("\d+(.\d+)?[KMGT]$", val):
        e = {"K": 1, "M": 2, "G": 3, "T": 4}[val[-1]]
        return int(float(val[:-1]) * 1024 ** e)
    return val