Calculating closest and furthest possible diagonal intersections.

The lines going downward to the right are of the form $x-y=2^m-2^n$ for some $m,n$. The ones going up to the right are of the form $x+y=2^m+2^n$ for some $m,n$. Given an input $x,y$ you are asking for the maximum $y' \lt y$ such that either $x-y'=2^m-2^n$ or $x+y'=2^m+2^n$. To find the second: Let $z=x+y$, then set all the low order bits of $z$ to $0$ until you only have two $1$ bits left. This will be the value of $x+y'$. Some pseudocode that will get you there:
z=x+y

m=int(log2(z))

z'=z-2^m

n=int(log2(z'))

y'2=2^m+2^n-x

For the first, you can round $x-y$ up to the next higher power of $2$ to get $m$, then find the lowest $n$ such that $2^m-2^n \gt x-y$

z=x-y

m=int(log2(z))+1

z'=2^m-z

n=int(log2(z'))+1

y'1=x-2^m+2^n

and take the greater of the two y's. Is $x$ always greater than $y$?