How to calculate total number of bits in BitSet ob

2019-08-15 17:54发布

I want to calculate the total number of bits in a BitSet object. The method length returns the "logical size" of the BitSet: the index of the highest set bit in the BitSet plus one, while method cardinality will give the total number of bits set to 1 in the object.

I want to calculate the total number of bits including both 0s and 1s. How do I do that?

标签: java bits bitset
3条回答
相关推荐>>
2楼-- · 2019-08-15 18:25

How about BitSet.size()?.....

查看更多
男人必须洒脱
4楼-- · 2019-08-15 18:47

The site shows how to convert a BitSet to binary String. Then just calculate the string.length()

查看更多
登录 后发表回答