Bit Manipulation to check if kth bit of a number is set or not

Правка en1, от CP_Sucks, 2018-12-29 20:07:24

Given Number = n To check kth bit set or not To Do 1. int temp = 1<<(k-1) (if u assume LSB to be 1 then use k-1 otherwise if assume 0 use k) 2. AND temp with n 3. If result is non-zero then set otherwise not set.

Теги bit manipulation

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский CP_Sucks 2018-12-29 20:07:24 279 Initial revision (published)