Java.lang.StrictMath 类

java.lang.StrictMath.nextDown() 方法返回负方向上与参数相邻的浮点值无穷。在特殊情况下,它返回以下内容:

  • 如果任一参数为 NaN,则返回 NaN。
  • 如果参数为负无穷大,则结果为负无穷大。
  • 如果参数为零,则结果为 -Float.MIN_VALUE。

语法

public static float nextDown(float f)

参数

f 指定起始浮点值。

返回值

返回负无穷方向上与参数相邻的浮点值。

异常

无。

示例:

在下面的示例中,nextDown()方法返回负无穷方向上与参数相邻的浮点值。

import java.lang.*;

public class MyClass {
 public static void main(String[] args) {
  System.out.println(StrictMath.nextDown(2.55f)); 
  System.out.println(StrictMath.nextDown(10.1f));   
 }
}

上述代码的输出将是:

2.5499997
10.099999