Assume that x and y are already defined as being of type cha

Assume that x and y are already defined as being of type  char . Write a single expression that will return true if the lower four bits of x are the same as the lower four bits of y. [Note that this compiler doesn\'t accept binary constants , so use hexidecimal instead. I.e., for 0b00111111 use 0x3F.]

Solution

the expresion is hex(x & 0x0f) == hex(y & 0x0f) in python.

here is the console output

>>> y = 0x4444f;
>>> x = 0x1f;
>>> hex(x & 0x0f) == hex(y & 0x0f)
True
>>> x = 0x14;
>>> hex(x & 0x0f) == hex(y & 0x0f)
False

Assume that x and y are already defined as being of type char . Write a single expression that will return true if the lower four bits of x are the same as the

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site