mirror of
https://github.com/Hizenberg469/C1-Linux_SYS_Prog-AS-.git
synced 2026-04-19 18:32:24 +03:00
unevalutated Assignment 5
This commit is contained in:
@@ -168,6 +168,7 @@ print_bit_array(bit_array_t *bitarr){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
int
|
||||
main(int argc, char **argv){
|
||||
|
||||
48
bitmaps_imp/bitsop.c
Normal file
48
bitmaps_imp/bitsop.c
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* =====================================================================================
|
||||
*
|
||||
* Filename: bitsop.c
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* Version: 1.0
|
||||
* Created: 22/02/24 09:24:28 AM IST
|
||||
* Revision: none
|
||||
* Compiler: gcc
|
||||
*
|
||||
* Author: YOUR NAME (),
|
||||
* Organization:
|
||||
*
|
||||
* =====================================================================================
|
||||
*/
|
||||
|
||||
uint8_t
|
||||
count_bit_set(uint32_t n){
|
||||
uint8_t bit_cnt = 0;
|
||||
|
||||
for(int i = 0 ; i < 32 ; i++ ){
|
||||
if( n&(1<<i)){
|
||||
bit_cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
return bit_cnt;
|
||||
}
|
||||
|
||||
void
|
||||
rotate_bit(uint32_t* n,int k){
|
||||
|
||||
int x=k,bit = 0;
|
||||
|
||||
while(x--){
|
||||
if( (*n)&(1<<31) ){
|
||||
bit = 1;
|
||||
}
|
||||
else{
|
||||
bit = 0;
|
||||
}
|
||||
|
||||
(*n)=(*n)<<1;
|
||||
(*n) |= 1;
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,16 @@
|
||||
#ifndef __BITS__
|
||||
#define __BITS__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define IS_BIT_SET(n, pos) ((n & (1 << (pos))) != 0)
|
||||
#define TOGGLE_BIT(n, pos) (n = n ^ (1 << (pos)))
|
||||
#define COMPLEMENT(num) (num = num ^ 0xFFFFFFFF)
|
||||
#define UNSET_BIT(n, pos) (n = n & ((1 << pos) ^ 0xFFFFFFFF))
|
||||
#define SET_BIT(n, pos) (n = n | 1 << pos)
|
||||
|
||||
uint8_t
|
||||
count_bit_set(uint32_t n);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user