昨晚在牛客APP上做JAVA题库,见到一题目很有新意,便对该问题和答案做了检验。
原题是这样的:
下列代码执行的结果应该是什么?
public class ZeroTest {
public static void main(String[] args) {
double x = -0.5d;
System.out.println(Math.floor(x));
System.out.println(Math.ceil(x));
x = Math.ceil(x);
System.out.println(x==0.0);
}
}
在MyEclipse运行下的正确答案是