Hey

So I need a prime number generator and this is what I came up with:
Code
class primeexample
{
public static void main (String[] args)
{
int n=3, divisor=2;
double mod;
boolean prime=true;
System.out.println(n-1);
while(true)
{
while(divisor<n)
{
mod=n%divisor;
if(mod==0)
{
prime=false;
}
divisor=divisor+1;
}
if (prime==true)
{
System.out.println(n);
}
n=n+1;
divisor=2;
prime=true;
}
}
}
My question is, with the proneness to errors of "double==x" statements, how can I find out for what values of n the program will stop working accurately? Second question is whether the mod==0 statement is avoidable (where mod is a double).