def dtype_calc(max_val):
    """Returns the dtype required to display the max val.

    args:
        max_val: set to negative to return signed int
    """
    dtype_list = [
        ['int8', 'int16', 'int32', 'int64'],
        ['uint8', 'uint16', 'uint32', 'uint64'],
    ]
    if max_val < 0:
        max_val *= -2
        dtype = dtype_list[0]
    else:
        dtype = dtype_list[1]
    if max_val <= 255:
        return dtype[0]
    elif max_val <= 65535:
        return dtype[1]
    elif max_val <= 4294967295:
        return dtype[2]
    else:
        return dtype[3]