0

I have an integer number, and the number can be expressed in 32 bits. And I want to count the number of true values.

For example: An integer 5566 can be expressed by 00000000 00000000 00010101 10111110, the number of true values is 9.

The calculation should consider the performance because it's used for a large data set.

In java, it seems that I need to convert the integer into byte[] first, and then convert into a boolean[] and then start counting, and I think there is a better way with better performance and less conversion.

Steven Chou
  • 1,504
  • 2
  • 21
  • 43

0 Answers0