Need to implement a bit_array of size 64. No external libraries except C standard ones. Need these main functions: bit_a

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Need to implement a bit_array of size 64. No external libraries except C standard ones. Need these main functions: bit_a

Post by answerhappygod »

Need to implement a bit_array of size 64.
No external libraries except C standard ones.
Need these main functions:
bit_array_allocate(int size)
bit_array_free(int position, int size)
printContents(bitArray)
EXAMPLE:
original bitmap:10111010010111100000000111111000010011010100010000000110011111000
Mallocate test cases in progress:
mem size of 1 can fit into address 0
mem size of 4 can fit into address 3
mem size of 8 can fit into address 14
USE TO PRINT BIT_ARRAY:
#include<stdio.h>
void Print_Binary(unsigned int Value);
int main(){
unsigned int x=0xF0F0F0F0; Print_Binary(x);}
void Print_Binary(unsigned int Value){ int i; unsigned int Mask = 1; Mask = Mask << 31; for(i=0; i<32; i++){ if((Mask & Value) == 0){ printf("0"); }else{ printf("1"); } Mask = Mask >> 1; } printf("\n");}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply