方法floor给出小于或等于参数的最大整数。
句法
- double floor(double d)
- double floor(float f)
参数 - 双精度或浮点型基本数据类型。
返回值 - 此方法返回小于或等于参数的最大整数。返回为双精度。
例子
下面是一个使用这个方法的例子 -
- class Example {
- static void main(String[] args) {
- double a = -100.675;
- float b = -90;
- System.out.println(Math.floor(a));
- System.out.println(Math.floor(b));
- }
- }
当我们运行上面的程序,我们将得到以下结果 -
- -101.0
- -90.0
转载本站内容时,请务必注明来自W3xue,违者必究。