This is an interview question: how to count set bits in float in Java ? I guess I should not know the bit representation of float to answer this question. Can I just convert a float to a byte array somehow? I can use the Java serialization but it looks like overkill.
Share
The Float class has an:
method that returns a representation of the specified floating-point value according to the IEEE 754 floating-point “single format” bit layout.
So you can get the bits with this method, then count which ones are set.
http://download.oracle.com/javase/7/docs/api/