반응형

Chapter 2. Basic

반응형

x & (x-1) 

Turn off the rightmost 1-bit in a word, producing 0 if none


x | (x+1)

Turn on the rightmost 0-bit in a word producing 1 if none


x & (x+1)

Turn off the trailing 1's in a word, producing x if none

It can check the form 2^n - 1, 0. 1


x | (x-1)

Turn on the trailing 0's in a word, producing x if none


¬x | (x – 1)

Creates a word with 1's at the positions of the trailing 0's in x and 0's elsewhere, producing 0 if none




반응형

이 글을 공유하기

댓글

Designed by JB FACTORY