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 class
public 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.0
f2: 0.0
f3: -Infinity
f4:  Infinity
d1: -0.0
d2: 0.0
d3: -Infinity
d4: InfinitynextUp(float):
StrictMath.nextUp (f1): 1.4E-45
StrictMath.nextUp (f2): 1.4E-45
StrictMath.nextUp (f4): InfinitynextUp(float):
StrictMath.nextUp (d1): 4.9E-324
StrictMath.nextUp (d2): 4.9E-324
StrictMath.nextUp (d4): Infinity

翻译自: https://www.includehelp.com/java/strictmath-nextup-method-with-example.aspx

strictmath

strictmath_Java StrictMath nextUp()方法与示例相关推荐

  1. java hypot_Java StrictMath hypot()方法与示例

    StrictMath类hypot()方法hypot()方法在java.lang包中可用. hypot()方法用于返回sqrt(sq(d1)+ sq(d2))的平方根,而不进行任何中间运算,换句话说,它 ...

  2. java abs在哪个包,Java StrictMath abs()方法

    Java StrictMath abs()方法 java.lang.StrictMath.abs(float a) 方法返回一个浮点值的绝对值.如果参数不是负数,则返回该参数.如果参数为负数,则返回该 ...

  3. java hypot_Java StrictMath hypot()方法

    Java StrictMath hypot()方法 java.lang.StrictMath.hypot() 方法返回 sqrt(x2 + y2) 没有中间溢或下溢.它包括了一些情况: 如果任一参数为 ...

  4. .net连接mysql数据_.net连接MYSQL数据库的方法及示例!

    连接MYSQL数据库的方法及示例 方法一: 使用MYSQL推出的MySQL Connector/Net is an ADO.NET driver for MySQL 该组件为MYSQL为ADO.NET ...

  5. set.difference() 的用法(python3)_Python 集合 difference_update() 使用方法及示例

    Python 集合 difference_update() 使用方法及示例 Difference_update()使用集合的差集更新集合,并调用difference_update()方法. 如果A和B ...

  6. doc python 颜色_Python wordcloud.ImageColorGenerator方法代码示例

    本文整理汇总了Python中wordcloud.ImageColorGenerator方法的典型用法代码示例.如果您正苦于以下问题:Python wordcloud.ImageColorGenerat ...

  7. isdigit函数在C语言什么意思,C 库函数 isdigit() 使用方法及示例

    C 库函数 isdigit() 使用方法及示例 isdigit()函数检查字符是否为数字字符(0-9). isdigit()的函数原型int isdigit( int arg ); 函数isdigit ...

  8. python中append的用法_Python 列表 append() 使用方法及示例

    Python 列表 append() 使用方法及示例 append()方法将一个项目添加到列表的末尾. append()方法将单个项目添加到列表的末尾. append()方法的语法为:list.app ...

  9. java kryo_Kryo框架使用方法代码示例

    Kryo框架的source已移至https://github.com/EsotericSoftware/kryo ,进入此页面,然后点击右边的Download Zip按钮,就能下载到最新版本的Kryo ...

最新文章

  1. 在线作图丨做一张叠加mantel test的相关性热图
  2. iOS开发学无止境 - UICollectionView自定义布局之风火轮[译]
  3. face_recognition快速入门
  4. 使用IDEA Maven搭建Mybatis环境
  5. 计算机学校教学大纲,中等职业学校计算机应用基础教学大纲
  6. linux fall delay 10,Cell的Rise delay和Fall delay、Rise transition和fall transition
  7. 小程序入门学习14--用户管理
  8. 谷歌和 Zyxel 各修复一个已遭利用的 0day
  9. Bailian2804 词典【map+字典树】
  10. C/C++中static与const的区别与联系
  11. linux的c文件报错for,安装Ubuntu时报错 Failed to load ldlinux.c32
  12. mysql data目录 恢复_利用mysql data文件夹恢复数据
  13. 电子电路设计——multisum中快捷设置555定时器
  14. python 树莓派实验一:跑马灯
  15. 网络----OSI模型
  16. MySQL 数据操作 DML细节
  17. 每日加瓦,终成栋房7-Object、Date、DateFormat、Calendar、System、StringBuider、包装类
  18. 在线教育网站的一些瞎折腾……
  19. hdu4504 威威猫系列故事——篮球梦 解题报告
  20. 黑客软件编写基础知识锦囊

热门文章

  1. ZOJ 3804 YY's Minions (简单模拟)
  2. AI编译器与传统编译器的联系与区别
  3. oracle标量子查询的优势,标量子查询
  4. git merge 回退_Git 基础学习总结2(学不会你锤我)
  5. c语言for循环26个英文字母,菜鸟求助,写一个随机输出26个英文字母的程序
  6. sed教程入门与实例练习(一)
  7. 10.6-全栈Java笔记:常见流详解(四)
  8. 《Python面向对象编程指南》——2.7 __del__()方法
  9. 连接fiddler后手机无法显示无网络
  10. Android 布局练习