java math 类

数学课静态长回合(双D) (Math Class static long round(double d) )

  • This method is available in java.lang package.

    此方法在java.lang包中可用。

  • This method is used to return the closest long value to the given argument.

    此方法用于将最接近的long值返回给定参数。

  • This is a static method, it is accessible with the class name too.

    这是一个静态方法,也可以使用类名进行访问。

  • The return type of this method is long, it returns the long type number which will be converted from double floating to long by adding 1/2 of the given argument.

    此方法的返回类型为long ,它返回long类型号,通过添加给定参数的1/2可以将其从double浮点数转换为long类型。

  • In this method, we pass only one parameter of a double type value.

    在此方法中,我们仅传递一个double类型值的参数。

  • If the value of the given argument after the 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 the decimal point is less than or equal to 4 then the same value before the decimal point is returned.

    如果小数点后给定参数的值大于4,则在返回小数点前将值加1;否则,如果小数点后给定参数的值小于或等于4,则相同返回小数点前的值。

  • This method does not throw any exception.

    此方法不会引发任何异常。

Syntax:

句法:

    public static long round(double d){
}

Parameter(s): d – a double value whose closest to long value to be found.

参数: d –一个双精度值,其最接近要找到的long值。

Note:

注意:

  • If we pass "NaN" (Not a Number), it returns 0.

    如果传递“ NaN”(非数字),则返回0。

  • If we pass negative infinity, it returns the "Long.MIN_VALUE".

    如果我们传递负无穷大,它将返回“ Long.MIN_VALUE”。

  • If we pass positive infinity, it returns the "Long.MAX_VALUE".

    如果我们传递正无穷大,它将返回“ Long.MAX_VALUE”。

  • If we pass the value which is less than or equal to "Long.MIN_VALUE", it returns "Long.MIN_VALUE".

    如果传递的值小于或等于“ Long.MIN_VALUE”,则返回“ Long.MIN_VALUE”。

  • If we pass the value which is greater than or equal to "Long.MAX_VALUE", it returns "Long.MAX_VALUE".

    如果传递的值大于或等于“ Long.MAX_VALUE”,则返回“ Long.MAX_VALUE”。

Return value:

返回值:

The return type of this method is long, it returns a long value which is the closest to long value of given parameter.

此方法的返回类型为long ,它返回一个long值,该值最接近给定参数的long值。

Java程序演示round(double d)方法的示例 (Java program to demonstrate example of round(double d) method)

// Java program to demonstrate the example of
// round(double d) method of Math Class.
public class RoundMethod {public static void main(String[] args) {// declaring the variables
double d1 = -1.0 / 0.0;
double d2 = 1.0 / 0.0;
double d3 = 1234.56;
double d4 = 1234.42;
// Here , we will get (Long.MIN_VALUE) and we are
// passing parameter whose value is (-Infinity)
System.out.println("Math.round(d1): " + Math.round(d1));
// Here , we will get (Long.MAX_VALUE) and we are
// passing parameter whose value is (Infinity)
System.out.println("Math.round(d2): " + Math.round(d2));
// Here , we will get (1235) and we are
// passing parameter whose value is (1234.56)
System.out.println("Math.round(d3): " + Math.round(d3));
// Here , we will get (1234) and we are
// passing parameter whose value is (1234.12)
System.out.println("Math.round(d4): " + Math.round(d4));
}
}

Output

输出量

E:\Programs>javac RoundMethod.java
E:\Programs>java RoundMethod
Math.round(d1): -9223372036854775808
Math.round(d2): 9223372036854775807
Math.round(d3): 1235
Math.round(d4): 1234

翻译自: https://www.includehelp.com/java/math-class-static-long-round-double-d-with-example.aspx

java math 类

java math 类_Java Math类静态长轮(double d)示例相关推荐

  1. java使用数学公式_java Math类数学公式运算

    java Math类数学公式运算.Math类 java提供了基本的+,-,*,/算数运算符,同时也提供了更复杂的运算符,比如三角函数,对数元,指数运算 Math是一个工具类.它的构造器被定义为priv ...

  2. java常用class类_java常用类

    java常用类 内部类 1.成员内部类:在一个类的内部定义一个完整的类 例如:外部类public class Body{ 内部类class Header{ } } 内部类可以直接访问外部类的私有成员, ...

  3. java 大数类_Java大数类介绍

    java能处理大数的类有两个高精度大整数BigInteger和高精度浮点数BigDecimal,这两个类位于java.math包内,要使用它们必须在类前面引用该包:import java.math.B ...

  4. java 比较器类_java常用类——比较器

    Comparable和Comparator接口都是为了对类进行比较,众所周知,诸如Integer,double等基本数据类型,java可以对他们进行比较,而对于类的比较,需要人工定义比较用到的字段比较 ...

  5. java file 工具_JAVA文件类工具

    FileUtil package cn.jiangzeyin.util.file; import org.springframework.util.Assert; import java.io.*; ...

  6. java math.sin()_Java Math sin() 使用方法及示例

    Java Math sin() 使用方法及示例 Java Math sin()返回指定角度的三角正弦值. sin()方法的语法为: Math.sin(double angle) sin()参数angl ...

  7. java void方法_Java对象类的最终void wait(long ms)方法,包含示例

    java void方法 对象类最终无效等待(长毫秒) (Object Class final void wait(long ms)) This method is available in java. ...

  8. java scanner 回车_Java Scanner类用法及nextLine()产生的换行符问题实例分析

    本文实例讲述了Java Scanner类用法及nextLine()产生的换行符问题.分享给大家供大家参考,具体如下: 分析理解:Scanner sc = new Scanner(System.in); ...

  9. java匿名类_Java匿名类

    java匿名类 Java anonymous class are like local class or inner class without a name. We can use java ano ...

最新文章

  1. 《Java 开发从入门到精通》—— 2.2 编写第一段Java程序
  2. 谈谈 Swift 中的 map 和 flatMap
  3. SQL Case when 的使用方法
  4. leetcode算法题--数组中两个数的最大异或值
  5. 台达变频器s1参数设置_【智】台达变频器计数输入功能接线和参数设置详解
  6. 【Qt】Qt工程管理
  7. python学习(四)--POST请求
  8. SAP Spartacus category navigation页面鼠标进入事件的处理
  9. DreamFactory 第8章 保护您的DreamFactory环境
  10. 如何将sinaweibo demo project 加入到 Three20UI中
  11. 获取以及自定义User-Agent在URLSession, NSURLConnection, WKWebView iOS
  12. 最全SolidWorks安装教程(附下载地址)-亲测可用
  13. C++二进制文件读写,以及数据的拼合与还原
  14. Php将mp3转wav,mp3转换成wav的经验方法
  15. 前端工程师的 caniuse
  16. exercsie13 参数 解包 变量
  17. win7如何用双显示屏,如何设置
  18. long 型应该加上 l或者L
  19. 关系数据模型的三个组成部分(关系数据模型的三个组成部分)
  20. Sass 你了解了吗

热门文章

  1. 52单片机iic读写c语言,如何52单片机的I2C读写24C08程序问题排查修改
  2. thinkcmf搭建教程_5分钟快速入门
  3. bootstrap源码之滚动监听组件scrollspy.js详解
  4. 重要·Flutter 首个预览版 发布
  5. CSS布局(五) 网页布局方式
  6. [团队项目3.0]Scrum团队成立
  7. !+\v1 用来“判断浏览器类型”还是用来“IE判断版本”的问题!
  8. C# 方法返回值的个数
  9. VB调用VC DLL函数
  10. hydra mysql 爆破_Hydra(爆破神器)使用方法