strictmath_Java StrictMath nextUp()方法与示例

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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/541341.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

并发数据结构-1.1 并发的数据结构的设计

原文链接,译文链接,译者:董明鑫,校对:周可人 随着多个处理器共享同一内存的机器在商业上的广泛使用,并发编程的艺术也产生了巨大的变化。当前的趋势向着低功耗芯片级多线程(CMT)发展…

printstream_Java PrintStream close()方法与示例

printstreamPrintStream类close()方法 (PrintStream Class close() method) close() method is available in java.io package. close()方法在java.io包中可用。 close() method is used to close the underlying output stream. close()方法用于关闭基础输出流。 close() meth…

oracle底层执行顺序,select语句结构与执行顺序-Oracle

select语句结构与执行顺序select语句的结构与执行顺序,下面的序号代表执行顺序8 SELECT (9)DISTINCT11 1 ROM 3   JOIN 2   ON 4 WHERE 5 GROUP BY 6 WITH {CUBE | ROLLUP}7 HAVING 10 ORDER BY 补…

HDU 4923 Room and Moor(瞎搞题)

瞎搞题啊。找出1 1 0 0这样的序列,然后存起来,这样的情况下最好的选择是1的个数除以这段的总和。然后从前向后扫一遍。变扫边进行合并。每次合并。合并的是他的前驱。这样到最后从t-1找出的那条链就是最后满足条件的数的大小。Room and Moor Time Limit:…

java define_Java Long类的define()方法与示例

java define长类解码()方法 (Long class decode() method) decode() method is available in java.lang package. 在java.lang包中提供了define ()方法 。 decode() method is used to decode the given String value into a Long value. encode()方法用于将给定的String值解码…

linux修改文件用户组,linux命令 修改文件、文件夹所属用户、用户组

最近学习hadoop,在替换配置文件的时候,发现老是报错,没有权限替换。我们知道如何改变文件的用户组与拥有者了,那么,什么时候要使用chown或chgrp呢?或许你会觉得奇怪吧?是的,确实有时…

Kotlin 开篇

Kotlin 是一个基于 JVM 的新的编程语言,由 JetBrains 开发官网地址:http://kotlinlang.org。JetBrains,作为目前广受欢迎的 Java IDE IntelliJ 的提供商,在 Apache 许可下已经开源其Kotlin 编程语言。开源地址:https:/…

inputstream示例_Java InputStream close()方法与示例

inputstream示例InputStream类close()方法 (InputStream Class close() method) close() method is available in java.io package. close()方法在java.io包中可用。 close() method is used to close this InputStream and free all system resources linked with this stream…

linux下的文件系统,Linux根文件系统(“/”文件系统)下的目录介绍

Linux下的文件存储与Windows完全不同,Windows将系统文件存储在系统盘(比如说C:\下)Linux根本没有盘符到概念只有一个根文件系/,各个磁盘分区挂载在/media/下(或者/mnt/下)/下到如/etc,/proc,/bin,/dev,lib等很是让用惯了Windows的用户不解,下…

greenlet 详解

greenlet初体验回到顶部Greenlet是python的一个C扩展,来源于Stackless python,旨在提供可自行调度的‘微线程’, 即协程。generator实现的协程在yield value时只能将value返回给调用者(caller)。 而在greenlet中,target.switch&am…

Java Calendar toString()方法与示例

日历类toString()方法 (Calendar Class toString() method) toString() method is available in java.util package. toString()方法在java.util包中可用。 toString() method is used to string denotations of the calendar object. toString()方法用于对日历对象的符号进行字…

linux虚拟机怎么看var文件,一种获取Linux虚拟机内部日志的方法

一种获取Linux虚拟机内部日志的方法【技术领域】[0001]本发明涉及云计算管理技术领域,特别是指一种获取Linux虚拟机内部日志的方法。【背景技术】[0002]在云计算环境下,虚拟机被广泛使用,对于虚拟机的维护要求越来越高,当虚拟机出…

详细图解mongodb 3.4.1 win7x64安装

原文:http://www.cnblogs.com/yucongblog/p/6895983.html 详细图解,记录 win7 64 安装mongo数据库的过程。安装的版本是 MongoDB-win32-x86_64-2008plus-ssl-3.4.1-signed。 我下载的源文件:mongodb-win32-x86_64-2008plus-ssl-3.4.1-signed我…

java calendar_Java Calendar complete()方法与示例

java calendarCalendar类的complete()方法 (Calendar Class complete() method) complete() method is available in java.util package. complete()方法在java.util包中可用。 complete() method is used to fills in any non-set fields in the calendar fields. complete()方…

LXD 2.0 系列(十二):调试,及给 LXD 做贡献

介绍 终于要结束了!这个大约一年前开始的这系列文章的最后一篇博文。 LXD 入门安装与配置你的第一个 LXD 容器资源控制镜像管理远程主机及容器迁移LXD 中的 DockerLXD 中的 LXD实时迁移LXD 和 JujuLXD 和 OpenStack调试,及给 LXD 做贡献如果你从一开始就…

linux用ping命令测试网速,linux下面使用命令测试网速

大家都知道在speedtest是市面上最准确最全面的测速工具,但在linux命令行不能直接使用,所以我们就借助脚本调用speedtest的接口来利用他测试网速。1.下载speedtest-cli脚本:下载地址:https://raw.githubusercontent.com/sivel/spee…

Java ArrayList isEmpty()方法与示例

ArrayList类isEmpty()方法 (ArrayList Class isEmpty() method) isEmpty() method is available in java.util package. isEmpty()方法在java.util包中可用。 isEmpty() method is used to check whether this Arraylist is "empty" or "not empty". isEmp…

linux家用系统版本,查看linux系统版本

篇一:linux下如何查看系统和内核版本linux下如何查看系统和内核版本 1. 查看内核版本命令:1) [rootq1test01 ~]# cat /proc/versionLinux version 2.6.9-22.ELsmp (bhcompilecrowe.devel.redhat.com) (gcc version 3.4.4 20050721 (Red Hat 3.4.4-2)) #1…

python中locked_Python锁类| 带示例的locked()方法

python中lockedPython Lock.locked()方法 (Python Lock.locked() Method) locked() is an inbuilt method of the Lock class of the threading module in Python. Locked()是Python中线程模块的Lock类的内置方法。 This method returns True if the lock is acquired by a th…

rocksdb ubuntu c++源码编译测试

2019独角兽企业重金招聘Python工程师标准>>> 环境: ubuntu16.4 需要安装 snappy gflage bz2 zstd 以及g 其中zstd是facebook开放源代码里的压缩的库 git clone https://github.com/facebook/rocksdb.git cd rocksdb make static_lib 成功生成 librocksd…