See my answer at:
http://mathoverflow.net/questions/22811/upper-bound-of-period-length-of-continued-fraction-representation-of-very-composi/23014#23014
Instead of using continued fractions to solve Pell's equation in the first place, thus needing high accuracy real numbers repeatedly, and needing a means to check the solution at the end, one may do the whole process in "reduced" indefinite binary quadratic forms.
The additional information used, over the earlier answer posted, is that the little 2 by 2 matrices (in the answer I call them $R$) show how to update your $(x,y)$ pair. At the end of the "cycle", you have come back to the reduced form $(1, 2 a_0, a_0^2 - n).$ The product of all the $R$ matrices in order give an automorph of that form, in particular the left hand column are the first $(x,y)$ such that $x^2 + 2 a_0 x y + (a_0^2 - n) y^2 = 1.$ All you need now is to pull back, $( x + a_0 y)^2 - n y^2 = 1.$ Here $a_0^2 < n < (a_0 + 1)^2.$
Here is a sample from my home computer. I am assuming you have arbitrary precision integer arithmetic, I do not.
My own program is not quite what I described, I give a separate automorph for the original Pell form $x^2 - n y^2$, then the unit is just the left column of that. let me know if you would like the C++ program.
As you can see, the upper right entry in the Pell automorph is oversize for C++, I had to fill in 61 * 226153980 and other values by hand.
phoebus:~/Cplusplus> ./Pell
Input n for Pell
61
0 form 1 14 -12 delta -1
1 form -12 10 3 delta 4
2 form 3 14 -4 delta -3
3 form -4 10 9 delta 1
4 form 9 8 -5 delta -2
5 form -5 12 5 delta 2
6 form 5 8 -9 delta -1
7 form -9 10 4 delta 3
8 form 4 14 -3 delta -4
9 form -3 10 12 delta 1
10 form 12 14 -1 delta -14
11 form -1 14 12 delta 1
12 form 12 10 -3 delta -4
13 form -3 14 4 delta 3
14 form 4 10 -9 delta -1
15 form -9 8 5 delta 2
16 form 5 12 -5 delta -2
17 form -5 8 9 delta 1
18 form 9 10 -4 delta -3
19 form -4 14 3 delta 4
20 form 3 10 -12 delta -1
21 form -12 14 1 delta 14
22 form 1 14 -12
disc 244
Automorph, written on right of Gram matrix:
-183241189 -2713847760
-226153980 -3349396909
Pell automorph
-1766319049 -13795392780
-226153980 -1766319049
Pell unit
1766319049^2 - 61 * 226153980^2 = 1
=========================================
phoebus:~/Cplusplus>