본문으로 바로가기
// extract k bits from a given position.

#include <stdio.h>
  
// Function to extract k bits from p position
// and returns the extracted value as integer
int bitExtracted(int number, int k, int p)
{
    return (((1 << k) - 1) & (number >> (p - 1)));
}
  
// Driver code
int main()
{
    int number = 171, k = 5, p = 2;
    printf("The extracted number is %d", bitExtracted(number, k, p));
    return 0;
}

 

'블로그 (Blog) > 개발로그 (Devlogs)' 카테고리의 다른 글

Normal Quantization  (0) 2024.03.08
Advanced Clipping Techniques  (0) 2024.03.07
vtk cell 타입  (0) 2024.03.07
n bytes 에서 특정 bit 영역만 추출  (0) 2024.03.07
libpng warning: iCCP: known incorrect sRGB profile  (0) 2024.03.07