Wrong answer in Xor PRofit Problem

what is wrong in my code?
#include
using namespace std;

int main() {

int x,y;
cin>>x;
cin>>y;

int a=x;
int b=y;
int xr;
int max=0;
while(a<=b){
xr=a^b;
a++;
b–;
if(xr>max){
max=xr;
}
}

cout<<max<<endl;

return 0;
}

@anikcode hey aniket your code is not giving right output for this senario like
1
1000
your output is 1001
but expected output is 1023

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.