Is it possible to check if two numbers are equal only with arithmetic operators?

35 Views Asked by At

I'm trying to find a function f(x,y) that returns 1 if the numbers are equal or 0 otherwise.

But I cannot wrap my head around it since I can't use functions like floor/ceil/absolute val.

1

There are 1 best solutions below

3
On BEST ANSWER

This suggestion may raise a heated discussion, but $$f(x,y)=0^{(x-y)^2}$$ works. Note that $0^0=1$ whereas $0^a=0$ for any $a>0$.