strictmath

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

  • rint() Method is available in java.lang package.

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

  • rint() Method is used to return the double type value and if the value of the given argument after decimal point is greater than 4 then the value is incremented by 1 before the decimal point is returned else if the value of the given argument after decimal point is less than or equal to 4 then the same value before the decimal point is returned.

    rint()方法用于返回双精度类型值,如果小数点后给定参数的值大于4,则在返回小数点前将值加1,否则,如果小数点后给定参数的值如果小数点小于或等于4,则返回小数点前的相同值。

  • rint() Method is a static method so it is accessible with the class name and if we try to access the method with the class object then we will not get any error.

    rint()方法是一个静态方法,因此可以使用类名进行访问,如果尝试使用类对象访问该方法,则不会出现任何错误。

  • rint() Method does not throw any exception.

    rint()方法不会引发任何异常。

Syntax:

句法:

    public static double rint(double d);

Parameter(s):

参数:

  • double d – represents a double type value.

    double d –表示双精度型值。

Return value:

返回值:

The return type of the method is double, it returns the double floating point number which will be equivalent to mathematical integer.

该方法的返回类型为double ,它返回等于数学整数的双精度浮点数。

Note:

注意:

  • If we pass NaN, the method returns the NaN.

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

  • If we an infinity, the method returns the same (i.e. infinity).

    如果我们无穷大,则该方法将返回相同的值(即无穷大)。

  • If we pass an argument whose value after the decimal point is greater than 4, the method returns the value incremented by 1 before the decimal point.

    如果我们传递的参数的小数点后的值大于4,则该方法返回的值在小数点前增加1。

  • If we pass zero, the method returns the same value with the same sign.

    如果传递零,则该方法返回具有相同符号的相同值。

Example:

例:

// Java program to demonstrate the example of
// rint(double d) method of StrictMath Class.
public class Rint {public static void main(String[] args) {// variable declarations
double d1 = -0.0;
double d2 = 0.0;
double d3 = -1.0 / 0.0;
double d4 = 1.0 / 0.0;
double d5 = 1234.56;
double d6 = 1234.12;
// Here , we will get (-0.0) because we are
// passing parameter whose value is (-0.0)
System.out.println("StrictMath.rint(d1): " + StrictMath.rint(d1));
// Here , we will get (0.0) and we are
// passing parameter whose value is (0.0)
System.out.println("StrictMath.rint(d2): " + StrictMath.rint(d2));
// Here , we will get (-Infinity) and we are
// passing parameter whose value is (-Infinity)
System.out.println("StrictMath.rint(d3): " + StrictMath.rint(d3));
// Here , we will get (Infinity) and we are
// passing parameter whose value is (Infinity)
System.out.println("StrictMath.rint(d4): " + StrictMath.rint(d4));
// Here , we will get (1235.0) and we are
// passing parameter whose value is (1234.56)
System.out.println("StrictMath.rint(d5): " + StrictMath.rint(d5));
// Here , we will get (1234.0) and we are
// passing parameter whose value is (1234.12)
System.out.println("StrictMath.rint(d6): " + StrictMath.rint(d6));
}
}

Output

输出量

StrictMath.rint(d1): -0.0
StrictMath.rint(d2): 0.0
StrictMath.rint(d3): -Infinity
StrictMath.rint(d4): Infinity
StrictMath.rint(d5): 1235.0
StrictMath.rint(d6): 1234.0

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

strictmath

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

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

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

  2. java math rint_Java Math rint() 使用方法及示例

    Java Math rint() 使用方法及示例 Java Math rint()方法返回最接近指定值且等于数学整数的值. 也就是说,如果指定值为5.8,则等于数学整数的最接近值是6.0.而对于值5. ...

  3. java math rint_Java Math.rint() 方法

    Java Math.rint() 方法 java.lang.Math.rint() 用于舍入参数最接近的整数. 1 语法 public static double rint(double x) 2 参 ...

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

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

  5. java hypot_Java StrictMath hypot()方法

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

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

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

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

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

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

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

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

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

最新文章

  1. 用鸿蒙跑了个 “hello world”!鸿蒙开发初体验
  2. 洛谷 P1678 烦恼的高考志愿
  3. 桌面虚拟化对企业IT的四大贡献
  4. eclipse Indigo Helios Galileo几种版本的意思
  5. 006 CSS三种引入方式
  6. SAP历史库存MB5B的详解
  7. C语言用warshall算法求传递闭包transitive closure(附完整源码)
  8. Resize Datafile时ORA-03297: 文件包含在请求的 RESIZE 值以外使用的数据
  9. 热榜!!!数据结构与算法:C语言版---数组与稀疏矩阵---强势来袭!
  10. [你必须知道的.NET]第十六回:深入浅出关键字---using全接触
  11. 安全云盘项目(一):1.5 bufferevent服务端代码事件策略
  12. 计算机系统的输入与输出接口是,计算机输入输出系统与接口技术
  13. shell实例100例《六》
  14. GIS基础软件技术体系发展及展望
  15. VC++_2010_学习版_下载教程
  16. 全新一代智慧园区数字孪生解决方案,为园区运营商和集成商赋能
  17. 利用opencv剪切图片
  18. Discuz仿今日头条模板/Discuz新闻资讯商业版GBK模板
  19. 计算机系统维护技术txt,计算机系统维护技术作业装系统.docx
  20. 第六学:binder---client与server向SM的求学之路

热门文章

  1. docker搭建ldap
  2. 【Docker】容器镜像有哪些特性
  3. nginx中的nginx.conf.default配置
  4. CentOS7启用SELinux和Firewall修改ssh端口号
  5. python测试工具开发面试宝典3web抓取
  6. 团队作业8—团队项目用户验收评审
  7. CycleGAN 各种变变变
  8. iOS7时代我们用什么来追踪和识别用户?
  9. apache 添加下载文件头
  10. 选择软路由的七大理由