Solution (source code)

= Solution

Split each input into its more and less significant $n$-<bit> halves: $a=2^na_H+a_L$ and $b=2^nb_H+b_L$. Let the two <digital comparators> produce $(L_H,G_H)$ and $(L_L,G_L)$. The more significant halves are equal exactly when $E_H=\neg(L_H\lor G_H)$. The <comparator composition> is therefore
$$
\boxed{L=L_H\lor(E_H\land L_L),\qquad G=G_H\lor(E_H\land G_L).}
$$
Implement $E_H$ with a <logical disjunction> followed by a <negation>, then use two <AND gates> and two more <logical disjunction> <logic gates>. If $a_H\ne b_H$, the difference $2^n(a_H-b_H)$ has magnitude at least $2^n$, whereas $|a_L-b_L|\le2^n-1$; hence the more significant comparison decides the result. If $a_H=b_H$, the lower comparison decides it. This proves correctness in every case using a constant number of extra <logic gates>.