博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
strictmath_Java StrictMath nextUp()方法与示例
阅读量:2529 次
发布时间:2019-05-11

本文共 4093 字,大约阅读时间需要 13 分钟。

strictmath

StrictMath类nextUp()方法 (StrictMath Class nextUp() method)

Syntax:

句法:

public static float nextUp(float fl);    public static double nextUp(double do);
  • nextUp() method is available in java.lang package.

    nextUp()方法在java.lang包中可用。

  • nextUp(float fl) method is used to return the float floating-point number adjacent to the given argument (fl) in the direction of the path of infinity.

    nextUp(float fl)方法用于返回沿无穷大路径方向与给定参数(fl)相邻的float浮点数。

  • nextUp(double do) method is used to return the double floating-point number adjacent to the given argument (do) in the direction of the path of infinity.

    nextUp(double do)方法用于在无穷大路径的方向上返回与给定参数(do)相邻的双浮点数。

  • These methods don't throw an exception.

    这些方法不会引发异常。

  • These are static methods, it is accessible with the class name and, if we try to access these methods with the class object then we will not get any error.

    这些是静态方法,可以通过类名进行访问,如果尝试使用类对象访问这些方法,则不会出现任何错误。

Parameter(s):

参数:

  • float fl/ double do – it represents the initial or starting floating-point value of float or double type.

    float fl / double do –表示floatdouble类型的初始或起始浮点值。

Return value:

返回值:

The return type of this method is float / double – it returns the floating-point number adjacent to the given parameter which is nearby infinity.

此方法的返回类型为float / double-返回与给定参数(无穷大附近)相邻的浮点数。

Note:

注意:

  • If we pass NaN, the method returns NaN.

    如果传递NaN,则该方法返回NaN。

  • If we pass a positive infinity, the methods returns the same (i.e. a positive infinity).

    如果我们传递一个正无穷大,则这些方法将返回相同的值(即一个正无穷大)。

  • If we pass 0 (positive or negative), the method returns Float.MIN_VALUE / Double.MIN_VALUE.

    如果传递0(正数或负数),则该方法返回Float.MIN_VALUE / Double.MIN_VALUE

Example:

例:

// Java program to demonstrate the example // of nextUp() method of StrictMath classpublic class NextUp {
public static void main(String[] args) {
// variable declarations float f1 = -0.0f; float f2 = 0.0f; float f3 = -7.0f / 0.0f; float f4 = 7.0f / 0.0f; double d1 = -0.0; double d2 = 0.0; double d3 = -7.0 / 0.0; double d4 = 7.0 / 0.0; // Display previous value of f1,f2,f3 and f4 System.out.println("f1: " + f1); System.out.println("f2: " + f2); System.out.println("f3: " + f3); System.out.println("f4: " + f4); // Display previous value of d1,d2,d3 and d4 System.out.println("d1: " + d1); System.out.println("d2: " + d2); System.out.println("d3: " + d3); System.out.println("d4: " + d4); System.out.println(); System.out.println("nextUp(float): "); // Here , we will get (Float.MIN_VALUE) because we are // passing parameter whose value is (-0.0f) System.out.println("StrictMath.nextUp (f1): " + StrictMath.nextUp(f1)); // Here , we will get (Float.MIN_VALUE) and we are // passing parameter whose value is (0.0f) System.out.println("StrictMath.nextUp (f2): " + StrictMath.nextUp(f2)); // Here , we will get (Infinity) and we are // passing parameter whose value is (7.0f/0.0f) System.out.println("StrictMath.nextUp (f4): " + StrictMath.nextUp(f4)); System.out.println(); System.out.println("nextUp(float): "); // Here , we will get (Double.MIN_VALUE) because we are // passing parameter whose value is (-0.0) System.out.println("StrictMath.nextUp (d1): " + StrictMath.nextUp(d1)); // Here , we will get (Double.MIN_VALUE) and we are // passing parameter whose value is (0.0) System.out.println("StrictMath.nextUp (d2): " + StrictMath.nextUp(d2)); // Here , we will get (Infinity) and we are // passing parameter whose value is (7.0/0.0) System.out.println("StrictMath.nextUp (d4): " + StrictMath.nextUp(d4)); }}

Output

输出量

f1: -0.0f2: 0.0f3: -Infinityf4:  Infinityd1: -0.0d2: 0.0d3: -Infinityd4: InfinitynextUp(float): StrictMath.nextUp (f1): 1.4E-45StrictMath.nextUp (f2): 1.4E-45StrictMath.nextUp (f4): InfinitynextUp(float): StrictMath.nextUp (d1): 4.9E-324StrictMath.nextUp (d2): 4.9E-324StrictMath.nextUp (d4): Infinity

翻译自:

strictmath

转载地址:http://satzd.baihongyu.com/

你可能感兴趣的文章
CentOS-6.3安装配置Nginx
查看>>
女陔说"你不懂我", 到底什么意思
查看>>
uva11149
查看>>
S/4HANA中的销售计划管理
查看>>
【图灵学院09】RPC底层通讯原理之Netty线程模型源码分析
查看>>
非常的好的协同过滤入门文章(ZZ)
查看>>
数据结构:哈希表
查看>>
markdown 基本语法
查看>>
tensorflow之tf.slice()
查看>>
Python高阶函数-闭包
查看>>
Windows下安装Redis
查看>>
Ubuntu 12.04 部署 PostGIS 2.1
查看>>
手机web——自适应网页设计(html/css控制)
查看>>
*[codility]CartesianSequence
查看>>
Hadoop1重新格式化HDFS
查看>>
HttpClientUtil工具类
查看>>
random模块
查看>>
Windows FindFirstFile利用
查看>>
使用mptt在easyui中显示树形结构
查看>>
冒泡排序
查看>>