helloworld:algorithms:numbers
Ceci est une ancienne révision du document !
Déterminer le nombre de bits levés dans un nombre
Code C : (dépendant de gcc)
__builtin_popcount(i);
Using the GNU Compiler Collection (GCC): Other Builtins Archive
Code C# :
static public uint NumberOfSetBits(uint i) { i = i - ((i >> 1) & 0x55555555); i = (i & 0x33333333) + ((i >> 2) & 0x33333333); return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24; }
helloworld/algorithms/numbers.1501688108.txt.gz · Dernière modification : 2017/08/02 17:35 de root