java math 类_Java Math类静态长轮(double d)示例

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 类

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

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

相关文章

C——求平均成绩

Problem Description 假设一个班有n(n<50)个学生&#xff0c;每人考m(m<5)门课&#xff0c;求每个学生的平均成绩和每门课的平均成绩&#xff0c;并输出各科成绩均大于等于平均成绩的学生数量。 Input 输入数据有多个测试实例&#xff0c;每个测试实例的第一行包括两个…

依赖、关联、聚合、组合还有泛化的关系(转载)

依赖、关联、聚合、组合还有泛化的关系 此文为转载文章:http://zjzkiss.cnblogs.com/世界是普遍联系的&#xff0c;因此程序世界中的类&#xff0c;也不可能是孤立的。UML为我们定义了它们之间的关系&#xff0c;就是&#xff1a;依赖、关联、聚合、组合还有泛化。 泛化关系比…

神奇的LINQ ---可以通过对象来查询数据

摘要&#xff1a; linq:在一个新项目里面要用这个技术&#xff0c;然后自己拿起书看了下&#xff0c;记录下自己的新发现&#xff0c;只适合简单入门的新童鞋看呀&#xff01;&#xff01;&#xff01; 结论&#xff1a; linq是对象领域与数据领域的一个桥梁。 为什么会出现Lin…

java math.cos_Java Math类静态double cos(double d)示例

java math.cos数学类静态双cos(double d) (Math Class static double cos(double d)) This method is available in java.lang package. 此方法在java.lang包中可用。 This method is used to return the trigonometric cosine of an angle of the given parameter in the meth…

web安全---SSRF漏洞

简介 SSRF&#xff1a;服务器请求伪造&#xff0c;是一种攻击者构造形成由服务端发起请求 的一个安全漏洞。一般情况下&#xff0c;SSRF攻击的目标是从外网无法访问的内部系统&#xff08;正是因为它是由服务端发起的&#xff0c;所以它能够请求到与它相连而与外网隔离的内部系…

集合——对象数组(引用数据类型数组)

案例&#xff1a;我有5个学生&#xff0c;请把这个5个学生的信息存储到引用数据类型数组中&#xff0c;并遍历数组&#xff0c;获取得到每一个学生的信息。 思路分析&#xff1a;首先&#xff0c;想要创建学生对象&#xff0c;就得有学生这个类&#xff0c;所以&#xff0c;首…

提升应用视觉Android效果的10个UI技巧

在Android应用开发中&#xff0c;风格和设计或许不是最关键的要素&#xff0c;但它们在决定Android应用成功与否上确实扮演重要的角色。以下是10个Android应用的UI设计技巧&#xff0c;还有个附加技巧&#xff0c;能够提供你的Android应用的视觉吸引力。 技巧1&#xff1a;使用…

kotlin中判断字符串_Kotlin程序查找字符串中字符的频率

kotlin中判断字符串Given a string and a character, we have to find the frequency of the character in the string. 给定一个字符串和一个字符&#xff0c;我们必须找到字符串中字符的频率。 Example: 例&#xff1a; Input:string "IncludeHelp"character to…

OD使用

0x01 功能界面 序号1是汇编代码对应的地址窗口序号2是汇编对应的十六进制机器码窗口序号3是反汇编窗口序号4是反汇编代码对应的注释信息窗口序号5是寄存器信息窗口序号6是当前执行到的反汇编代码的信息窗口序号7是数据所在的地址序号8是数据的十六进制编码信息&#xff0c;序号…

windows mobile 开发总结--菜单

在开发时经常要创建菜单&#xff0c;并且动态显示和隐藏菜单或者是某个子菜单。以下就是实现的方法&#xff1a; 1。创建并显示菜单,先在资源里添加菜单&#xff0c;然后如下代码 SHMENUBARINFO mbi; ZeroMemory(&mbi, sizeof(SHMENUBARINFO)); mbi.cbSizesizeof(SHMENUBAR…

Java——集合的概述

* A&#xff1a;集合的由来* 数组是容器&#xff0c;集合也是容器* 数组的弊端&#xff1a;数组的长度是固定的&#xff0c;当添加的元素超过了数组的长度时&#xff0c;需要对数组重新定义&#xff0c;太麻烦* Java内部给我们提供了集合类&#xff0c;可以存储任意对象&#x…

排序算法中平均时间复杂度_操作系统中的作业排序(算法,时间复杂度和示例)...

排序算法中平均时间复杂度作业排序 (Job sequencing) Job sequencing is the set of jobs, associated with the job i where deadline di > 0 and profit pi > 0. For any job i the profit is earned if and only if the job is completed by its deadline. To complet…

python---文件处理

0x01 打开一个文件 python中内置了文件对象&#xff0c;通过open()函数就可以制定模式打开指定文件&#xff0c;并创建文件对象。该函数的格式如下&#xff1a; open(file[,moder[,buffering-1]])file&#xff1a;指定要打开或创建的文件名称&#xff0c;如果该文件不存在当前…

简易而又灵活的Javascript拖拽框架(四)

一、开篇 似乎拖拽已经被写烂了&#xff0c;没得写的了&#xff0c;可是我这次又来了&#xff5e; 上一次写的是跨列拖放&#xff0c;这次我要带给大家的是跨页拖放。 可以到这里来看看效果&#xff1a;示例效果 说明&#xff1a;1、如果将方框拖动到页签上立刻释放掉的话&…

Java——集合的基本功能测试

* 1,boolean add<E,e> 添加* 确保此 collection 包含指定的元素&#xff08;可选操作&#xff09;。* 参数&#xff1a;e - 确定此 collection 中是否存在的元素。E - 代表Object类&#xff0c;说明该add可以添加任何对象&#xff0c;任意对象都是Object的子类对象&…

《那些年啊,那些事——一个程序员的奋斗史》——78

招人风波之后&#xff0c;就很少见武总往18楼跑了&#xff0c;大部分时间都是坐在22楼的隔间。而武总对段伏枥的抱怨&#xff0c;也仅仅只有那次&#xff0c;后来就再也没有提过。对于段伏枥而言&#xff0c;还要不要招新人&#xff0c;后续如何去招新人&#xff0c;已经不是自…

python---异常处理结构

python中提供了很多不同形式的异常处理结构&#xff0c;其基本思路都是先尝试执行代码&#xff0c;再处理可能发生的错误。 try…except… 在python异常处理结构中&#xff0c;try…except…使用最为频繁&#xff0c;其中try子句中的代码块为可能引发异常的语句&#xff0c;e…

用css网站布局之十步实录 (转载)

第一步&#xff1a;规划网站http://www.52css.com/article.asp?id175 第二步&#xff1a;创建html模板及文件目录等http://www.52css.com/article.asp?id176 第三步&#xff1a;将网站分为五个div 网页基本布局http://www.52css.com/article.asp?id177 第四步&#xff1a;网…

Java——集合转数组并对其进行遍历

* A&#xff1a;集合的遍历* 其实就是以此获取集合中的每一个元素* B&#xff1a;案例* 把集合转成数组&#xff0c;可以实现集合的遍历* public Object[] toArray() 按适当顺序&#xff08;从第一个到最后一个元素&#xff09;返回包含此列表中所有元素的数组。…

鱼油账号记录程序(续) - 零基础入门学习Delphi39

鱼油账号记录程序&#xff08;续&#xff09; 让编程改变世界 Change the world by program 课件同上一讲&#xff0c;这一讲主要演示编程操作和修改程序&#xff01; [buy] 获得所有教学视频、课件、源代码等资源打包 [/buy] [Downlink hrefhttp://kuai.xunlei.com/d/LDKX…