What is displayed when the following is executed

What is displayed when the following is executed;java

double d1=-0.5;
System.out.println("Ceil d1="+Math.ceil(d1));
System.out.println("floor d1="+Math.floor(d1));

 

  • Ceil d1=-0.0
    floor d1=-1.0
  • Ceil d1=0.0
    floor d1=-1.0
  • Ceil d1=-0.0
    floor d1=-0.0
  • Ceil d1=0.0
    floor d1=0.0
  • Ceil d1=0
    floor d1=-1

Acode

  • ceil:大于等于 x,而且与它最接近的整数。
  • floor:小于等于 x,且与 x 最接近的整数。
  • 若是参数小于0且大于-1.0,结果为 -0
相关文章
相关标签/搜索