Here my stab at porting the algorithm from Solution 2 to BigInteger.
using namespace System;
using namespace System::Numerics;
...
static BigInteger SQRT(BigInteger y)
{
if (y <= BigInteger::Zero)
{
if (y != BigInteger::Zero)
{
return BigInteger::Negate(BigInteger::One);
}
return BigInteger::Zero;
}
BigInteger x_old(4);
BigInteger testy(16);
while(true)
{
if ( y <= testy)
{
break;
}
testy <<= 2L;
x_old <<= 1L;
}
BigInteger x_new;
while(true)
{
x_new = (BigInteger::Add( (y / x_old), x_old ) ) / 2L;
if (x_old <= x_new)
{
break;
}
x_old = x_new;
}
return x_old;
}
Hope that helps.