博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
java math 类_Java Math类静态长轮(double d)示例
阅读量:2531 次
发布时间:2019-05-11

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

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.javaE:\Programs>java RoundMethodMath.round(d1): -9223372036854775808Math.round(d2): 9223372036854775807Math.round(d3): 1235Math.round(d4): 1234

翻译自:

java math 类

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

你可能感兴趣的文章
小D课堂 - 新版本微服务springcloud+Docker教程_5-02 Netflix开源组件断路器
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_5-01分布式核心知识之熔断、降级
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_5-04 feign结合hystrix断路器开发实战下...
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_5-03 feign结合hystrix断路器开发实战上...
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_6-01 微服务网关介绍和使用场景
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_5-05熔断降级服务异常报警通知
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_6-03 高级篇幅之zuul常用问题分析
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_5-08 断路器监控仪表参数
查看>>
小D课堂 - 新版本微服务springcloud+Docker教程_6-02 springcloud网关组件zuul
查看>>
小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_2-1.快速搭建SpringBoot项目,采用Eclipse...
查看>>
小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_1-4.在线教育后台数据库设计...
查看>>
小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_2-3.热部署在Eclipse和IDE里面的使用...
查看>>
小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_1-3.在线教育站点需求分析和架构设计...
查看>>
小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_2-4.后端项目分层分包及资源文件处理...
查看>>
小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_2-2.快速搭建SpringBoot项目,采用IDEA...
查看>>
小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_3-5.PageHelper分页插件使用
查看>>
小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_5-6.微信扫码登录回调本地域名映射工具Ngrock...
查看>>
小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_5-8.用户模块开发之保存微信用户信息...
查看>>
Linux下Nginx安装
查看>>
LVM扩容之xfs文件系统
查看>>