« Les opérations bit à bit/Manipulations sur les bits de poids faible/fort » : différence entre les versions

Contenu supprimé Contenu ajouté
Ligne 765 :
===''Find First Set''===
 
Passons maintenant à l'opération '''Find First Set''', qui donne la position du 1 de poids faible. On a vu plus haut que l'on peut isoler ce bit, avec le calcul <math>x . (- x)</math>. Une fois ce bit isolé, on peut trouver sa position enavec calculantl'opération son''Find logarithmeHighest binaireSet''. On a donc :
 
<syntaxhighlight lang="c">
unsigned ffs (unsigned n)
{
return log_2fhs( x & -x ) ;
}
</syntaxhighlight>