subject

Suppose we number the bits in a 32-bit word from 0 (least significant) to 31 (most significant). Write code for the following C function that will return 1 if x has at least one bit with a value of 1 at an odd index, 0 otherwise: int oddBit(unsigned int x);
Here are some test runs:

oddBit (Oxl): 0 oddBit (0x2): 1
oddBit (0x3): 1 oddBit (0x4): 0
oddBit (0x): 1
oddBit (Ox): 1
oddBit (Ox55555555): 0

Use only bitwise and logical operators (&&, 11, !); no if statements, loops, arithmetic operators (+,-, *,7,%), or conditional operators (==, !=, etc). Also write a main() function to test your function. Hint: use a bit mask to isolate the odd bits, and think about the effect of a logical not (or two) on an int in C. Comment your code, including every line that uses a bitwise operator.

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 02:00, sabrinarasull1pe6s61
Which of the following is a way the operating system prevents unknown or unauthorized users from accessing the system?
Answers: 2
image
Computers and Technology, 22.06.2019 13:00, cookie1701
Why the bear has a slunky tail determine the meaning of the word slunk in the story
Answers: 1
image
Computers and Technology, 23.06.2019 09:30, shadowsnake
Write a function called checkfactor that takes two arrays of positive numbers, firstnumberrow and secondnumberrow. checkfactor checks if the first entry in firstnumberrow is divisible by the first entry in secondnumberrow, and performs the same operation on the next array elements until all entries have been checked. all the numbers are positive and the number of entries in the arrays are the same. the function should return the identified divisible numbers in two row arrays named firstdivisible and seconddivisible. restrictions: branches or loops should not be used. the code must use the internal mod and logical functions. hint: the mod function should be used to determine if two numbers are divisible. ex: for num1 and num2 if mod(num1,num2) is 0, then the two numbers are divisible. this is matlab
Answers: 2
image
Computers and Technology, 23.06.2019 21:40, jeovontamarley
language consists of basic components, and they are called a. 3; mental images, concepts, and speech b. 2; language acquisition and linguistic relativity c. 3; heuristics, algorithms, and analogies d. 4; phonemes, morphemes, syntax, and semantics e. 2; words and grammar
Answers: 3
You know the right answer?
Suppose we number the bits in a 32-bit word from 0 (least significant) to 31 (most significant). Wri...

Questions in other subjects:

Konu
Mathematics, 04.05.2021 01:00