compute tag length based on val