Check if $u + v\sqrt 2 > u' + v'\sqrt 2$ without computing $\sqrt 2$ I'm building an algorithm that perform some computations on two inputs, m and n. These are numbers of the form $u + v\sqrt 2$, where $u$ and $v$ are integers.
I'm asking here because at a certain point the algorithm checks if m $>$ n, and, in order of the algorithm to be effective, it must not use the infinite decimal expansion of $\sqrt 2$.
So how can I say about the possibility to perform that check exactly and in a finite length of time? Is there a way to do that?
Just to give an example, if it had been to check m $=$ n, that is $u + v\sqrt 2 = u' + v'\sqrt 2$, it would have been much simpler, because one would have just need to check that $u + v = u' + v'$, since $\sqrt 2$ is irrational.
What about, instead, the inequality? How to get rid of $\sqrt 2$?
 A: The only non obvious case is when $a=u-u'$ and $b=v'-v$ are nonzero and have the same sign. Assume for definiteness that $a$ and $b$ are positive. To check whether $a\gt b\sqrt2$ or $a\lt b\sqrt2$, compute $a^2$ and $2b^2$ and compare them.
A: The numbers in $a+b\sqrt{2}$ can be reduced to a form in base $1+\sqrt{2}$, such that all numbers in the set has a unique representation, and that that if one spelling is 'later' than another, than the later spelling is bigger, rather like decimals.
You can do this with coins on the table.  The two 'equalities' are shown in the model below.  This is to be done on a grid or abacus of two bases.  The idea is to reduce the collection to a double row, with no more than one stone in each column, and only '0', if the next column contains a '1'.
         b                                  . 1         1   1
      1  b      1 = a+a = b+b       2   =  1. 1     =   0   0  
      a  a                                              q . q

One can show the vertical base is $\sqrt{2}$ and the horizontal base is $1+\sqrt{2}$.  It is possible to reduce any combination of $x+y\sqrt{2}$ to a sum of digits $0,1,\sqrt{2}$ in a base $1+\sqrt{2}$, where none of the patterns show.
You can easily demonstrate this works, by feeding coins at the '1', and 'counting' in this base.  The numbers run ($q=\sqrt{2}$),  1, q.q, 10.q, q0.q, qq.01, 100.01, 101.01, 10q.q1, etc.  
This same algorithm can be used to test cases which are very near the size of the registers of a computer.  This is because it does not rely on calculating the square.  
The process is to start with $a(\sqrt{2}+)b$, and then calculate $A=a+b, b=A+a, a=A$.  Keep doing this until both come to the same sign, in which case the sign is the result.
For example, this tests whether $10$ is greater than $7\sqrt{2}$  3 comes from 10-7, -4 comes from -7+3, and this iterates.
   b   10  -4    2   0   1
   a   -7   3   -1   1   1

If you count the number of iterations (eg $c=0$, then $c=c+1$, then the difference at any stage is $(a\sqrt{2}+b)/(\sqrt{2}+1)^c$.   
