Question
I am not really sure what this question is even asking, if I could get some help reading the forumlas and making sense of the
I am not really sure what this question is even asking, if I could get some help reading the forumlas and making sense of the "help" the assignment gives it would be appericated.
Question:
Write C expressions to generate the bit patterns that follow, where ak represents k repetitions of symbol a. Assume a w-bit data type. Your code may contain references to parameters j and k, representing the values of j and k, but not a parameter representing w. Using constants such as INT_MIN and INT_MAX is not allowed since it is an indirect reference to the value of w.
Bit Pattern A. 1wk0k
Bit Pattern B. 0wkj1k0j
Your C expressions should be programmed in .c file with sample tests.
Your expression should follow the bit-level integer coding rules. This means solutions including loops are not valid.
"Help" given:
For bit pattern 1w , the answer is printf(%x , -1);
bit-level integer coding rules:
Assumptions
Integers are represented in twos-complement form.
Right shifts of signed data are performed arithmetically.
Data type int is w bits long. For some of the problems, you will be given a specific value for , but otherwise your code should work as long as is a multiple of 8. You can use the expression to compute .
Forbidden
Conditionals (if or ?:), loops, switch statements, function calls, and macro invocations.
Division, modulus, and multiplication.
Relative comparison operators (<, >, <=, and >=).
Casting, either explicit or implicit.
Allowed operations
All bit-level and logic operations.
Addition and subtraction.
Equality (==) and inequality (!=) tests. (Some of the problems do not allow
these.)
Integer constants INT_MIN and INT_MAX.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started