Question: I have the following solution for a function. Can you explain the code line by line? Thanks! Return 1 if the addresses stored in ptr1

I have the following solution for a function. Can you explain the code line by line? Thanks!

Return 1 if the addresses stored in ptr1 and ptr2 are within the *same* 64-byte aligned block of memory. Check the spec for examples if you are confused about what this means. Return zero otherwise. Operators / and % and loops are NOT allowed.

int withinSameBlock(int *ptr1, int *ptr2) { // Your code here long int a = (long int) ptr1; long int b = (long int) ptr2; return !((~(b >> 6) + 1) + (a >> 6)); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!