From ef55631cbda557e32c52beb36f9e7098af5b707e Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sun, 28 May 2017 18:51:54 +1000 Subject: [PATCH] Simplify bitMask calculation. --- lang/check/bounds.go | 17 +++++++---------- lang/check/check_test.go | 4 ++-- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/lang/check/bounds.go b/lang/check/bounds.go index 42e35cbc..b6de58ca 100644 --- a/lang/check/bounds.go +++ b/lang/check/bounds.go @@ -62,12 +62,9 @@ func max(i, j *big.Int) *big.Int { return j } -func roundUpToPowerOf2Minus1(i *big.Int) *big.Int { - if i.Cmp(zero) < 0 { - panic("unreachable") - } - bitLen := i.BitLen() - switch bitLen { +// bitMask returns (1<