public static void SqrtTest(int rounds)
{
Random rand = new Random();
for(int count = 0; count < rounds; count++)
{
// generate data of random length
int t1 = 0;
while(t1 == 0)
t1 = (int)(rand.NextDouble() * 1024);
Console.Write("Round = " + count);
BigInteger a = new BigInteger();
a.genRandomBits(t1, rand);
BigInteger b = a.sqrt();
BigInteger c = (b+1)*(b+1);
// check that b is the largest integer such that b*b <= a
if(c <= a)
{
Console.WriteLine("\nError at round " + count);
Console.WriteLine(a + "\n");
return;
}
Console.WriteLine(" <PASSED>.");
}
}