Closed rkshthrmsh closed 1 year ago
Thanks. Can you add some tests to tests/test_bitutils.py
? You can follow the pattern of the other tests in that file.
Added tests.
Patch coverage: 97.36%
and project coverage change: -0.03%
:warning:
Comparison is base (
4475c36
) 86.12% compared to head (1eeb035
) 86.09%. Report is 1 commits behind head on master.:exclamation: Current head 1eeb035 differs from pull request most recent head 4fb7cc2. Consider uploading reports for the commit 4fb7cc2 to get more accurate results
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@rkshthrmsh let's not include 2608825 in this PR, and do it separately
Worth noting that bit_length
is already a method on int
.
assert (16).bit_length() == 5
So probably no need to provide this as a utility.
@cdonovick, thanks for pointing this out. @rsetaluri, I think this PR can be closed in favor of the bit_length
method on int
.
Although
clog2
is provided as a utility function for approximating bit lengths from values, it fails in edge cases where the value itself is a power of 2. For example,clog2(16) = 4
, but 5 bits are needed to store the value 16. The right formula here would be:floor(log_2(16)) + 1
. Although most hardware designers might be aware of this, a helper function for bit length of any generic value could be helpful.