Hey everyone. I'm having trouble with this homework assignment and I would really appreciate some help/hints to get me started. I've basically been given a template and I have to fill in the functions. I'm only allowed to use &, |, ^, ~, !, >>, and << operators to complete this assignment. For example, the code below is one of the functions I need to fill in. For this specific one, I need to determine if the two ints are equal and return 'true'.
1 2 3 4
bool isEqual(int a, int b){
returntrue;
}
Let's say both a and b are equal to 7. How could I do this using only the operators listed above?
Another, slightly more difficult function I've been given is:
The isEqual() requires you to think about the bitwise operations (AND, OR, and XOR). One of those should allow you to combine the operands to get a unique result. (hint!)
The flipEndian() function requires the use of <<, >>, and &, and will require a loop. The only thing is that you will have to assume a number of bits in a short: use 16. You'll need your input (argument) and an output (initialize with zero).