static float min(float a, float b)
描述 (Description)
java.lang.StrictMath.min(float a, float b)方法返回两个float值中较小的一个。
如果参数具有相同的值,则结果是相同的值。 如果任一值为NaN,则结果为NaN。
该方法认为负零严格小于正零。 如果一个参数为正零而另一个参数为负零,则结果为负零。
声明 (Declaration)
以下是java.lang.StrictMath.min()方法的声明
public static float min(float a, float b)
参数 (Parameters)
a - 这是浮点值。
b - 这是另一个浮点值。
返回值 (Return Value)
此方法返回a和b中较小的一个。
异常 (Exception)
NA
例子 (Example)
以下示例显示了java.lang.StrictMath.min()方法的用法。
package com.iowiki;
import java.lang.*;
public class StrictMathDemo {
public static void main(String[] args) {
float f1 = 50 , f2 = 100, f3 = -25;
// both positive values
double minValue = StrictMath.min(f1, f2);
System.out.println("StrictMath.min(50, 100) : " + minValue);
// one positive and one negative value
minValue = StrictMath.min(f1, f3);
System.out.println("StrictMath.min(50, -25) : " + minValue);
}
}
让我们编译并运行上面的程序,这将产生以下结果 -
StrictMath.min(50, 100) : 50.0
StrictMath.min(50, -25) : -25.0