How to get amount of 1s from 64 bit number [duplicate]
问题 This question already has answers here : Count number of bits in a 64-bit (long, big) integer? (3 answers) Closed 6 years ago . Possible duplicate: Count number of bits in a 64-bit (long, big) integer? For an image comparison algorithm I get a 64bit number as result. The amount of 1s in the number (ulong) (101011011100...) tells me how similar two images are, so I need to count them. How would I best do this in C#? I'd like to use this in a WinRT & Windows Phone App, so I'm also looking for a