long i <= Math.sqrt(data)不同数据类型的比较为什么没有警告?
public static void main(String[] args) {
boolean flag = true;
System.out.print("Please input the number:");
Scanner input = new Scanner(System.in);
long data = input.nextLong();
System.out.println("The square root of "+data+" is "+Math.sqrt(data));
// 这儿有点不明白,i <= Math.sqrt(data)不同数据类型的比较为什么没有警告
for(long i = 2; i <= Math.sqrt(data); i ++)
{
if(data%i == 0)
{
flag = false;
break;
}
}
if(flag)
System.out.println(data+" is a prime.");
else
System.out.println(data+" is not a prime.");
}