java.lang.Math.floor() 用於查找小於或等於參數且等於 double 值的數學整數的最大整數值。
用法
public static double floor(double a)
參數
x= a value
返回
This method returns largest floating-point value that is less than or equal
to the argument and is equal to a mathematical integer of a double value.
- 如果參數為正或負雙精度值,此方法將返回 Floor 值。
- 如果參數為 NaN,則此方法將返回相同的參數。
- 如果參數為 Infinity,則此方法將返回與參數相同符號的 Infinity。
例子1
public class FloorExample1
{
public static void main(String[] args)
{
double x = 94.69;
// Input positive value, Output floor value of x
System.out.println(Math.floor(x));
}
}
輸出:
94.0
例子2
public class FloorExample2
{
public static void main(String[] args)
{
double x = -39.28;
// Input negative value, Output floor value of x
System.out.println(Math.floor(x));
}
}
輸出:
-40.0
例子3
public class FloorExample3
{
public static void main(String[] args)
{
double x = 0.0;
// Input positive zero, Output positive zero
System.out.println(Math.floor(x));
}
}
輸出:
0.0
示例 4
public class FloorExample4
{
public static void main(String[] args)
{
double x = -7.0 / 0;
// Input negative infinity, Output negative infinity
System.out.println(Math.floor(x));
}
}
輸出:
-Infinity
相關用法
- Java Math.floorDiv()用法及代碼示例
- Java Math.multiplyExact()用法及代碼示例
- Java Math.rint()用法及代碼示例
- Java Math.nextUp()用法及代碼示例
- Java Math.tan()用法及代碼示例
- Java Math.asin()用法及代碼示例
- Java Math.atan()用法及代碼示例
- Java Math.nextAfter()用法及代碼示例
- Java Math.exp()用法及代碼示例
- Java Math.tanh()用法及代碼示例
- Java Math.toDegrees()用法及代碼示例
- Java Math.getExponent()用法及代碼示例
- Java Math.toIntExact()用法及代碼示例
- Java Math.IEEEremainder()用法及代碼示例
- Java Math.sqrt()用法及代碼示例
- Java Math.incrementExact()用法及代碼示例
- Java Math.min()用法及代碼示例
- Java Math.log()用法及代碼示例
- Java Math.log1p()用法及代碼示例
- Java Math.signum()用法及代碼示例
注:本文由純淨天空篩選整理自 Java Math.floor() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。