通过最近的学习,学到了一些的Math类中的常见方法

package org.stm.demo;

public class Test {

public static void main(String[] args) {

    /**
* Math.abs(绝对值)
*/
System.out.println(Math.abs(-11.8)); //11.8
System.out.println(Math.abs(-0.0)); //0.0
/**
* Math.ceil(天花板)
*/
System.out.println(Math.ceil(-11.8)); //-11.0
System.out.println(Math.ceil(10.8)); //11.0
System.out.println(Math.ceil(-0.6)); //-0.0
System.out.println(Math.ceil(0.0)); //0.0
System.out.println(Math.ceil(-0.0)); //-0.0 /**
* Math.floor(地板)
*/
System.out.println(Math.floor(-11.1)); //-12.0
System.out.println(Math.floor(11.7)); //11.0
System.out.println(Math.floor(-0.7)); //-1.0
System.out.println(Math.floor(0.0)); //0.0
System.out.println(Math.floor(-0.0)); //-0.0 /**
* Math.max(arg0,arg1)
* Math.min(arg0,arg1)
*/
System.out.println(Math.max(-11.1, -11)); //-11.0
System.out.println(Math.max(11.7, 11)); //11.7
System.out.println(Math.max(0.0, -0.0)); //0.0 /**
* round 四舍五入,float时返回int值,double时返回long值
* Math.round(x) = Math.floor(x+0.5)
*/
System.out.println(Math.round(10.1)); //10
System.out.println(Math.round(10.7)); //11
System.out.println(Math.round(10.5)); //11
System.out.println(Math.round(10.51)); //11
System.out.println(Math.round(-10.5)); //-10
System.out.println(Math.round(-10.51)); //-11
System.out.println(Math.round(-10.6)); //-11
System.out.println(Math.round(-10.2)); //-10 /**
* rint 四舍五入,返回double值
* 注意.5的时候会取偶数
*/
System.out.println(Math.rint(10.1)); //10.0
System.out.println(Math.rint(10.7)); //11.0
System.out.println(Math.rint(11.5)); //12.0
System.out.println(Math.rint(10.5)); //10.0
System.out.println(Math.rint(10.51)); //11.0
System.out.println(Math.rint(-10.5)); //-10.0
System.out.println(Math.rint(-11.5)); //-12.0
System.out.println(Math.rint(-10.51)); //-11.0
System.out.println(Math.rint(-10.6)); //-11.0
System.out.println(Math.rint(-10.2)); //-10.0
}

}

如果大家有疑问,可评论,也可以到APl中查到相应的用法以及到编辑器里面不妨一试!加油>>>

在java中浅谈Math类中的常用方法的更多相关文章

  1. Math类中的BigDecimal

    如果我们编译运行下面这个程序会看到什么? public class Test {    public static void main(String args[]) {                 ...

  2. 转:浅谈C/C++中的指针和数组(一)

    再次读的时候实践了一下代码,结果和原文不一致 error C2372: 'p' : redefinition; different types of indirection 不同类型的间接寻址 /// ...

  3. 转载 浅谈C/C++中的static和extern关键字

    浅谈C/C++中的static和extern关键字 2011-04-21 16:57 海子 博客园 字号:T | T   static是C++中常用的修饰符,它被用来控制变量的存贮方式和可见性.ext ...

  4. Math类中round、ceil和floor方法的功能

    Java中的Math工具类用来完成除+.-.*./.%等基本运算以外的复杂运算,位于java.lang包下,Math类的构造器全是私有的(private),因此无法创建Math类的对象,Math类的方 ...

  5. 浅谈关于QT中Webkit内核浏览器

    关于QT中Webkit内核浏览器是本文要介绍的内容,主要是来学习QT中webkit中浏览器的使用.提起WebKit,大家自然而然地想到浏览器.作为浏览器内部的主要构件,WebKit的主要工作是渲染.给 ...

  6. 浅谈 Swift 2 中的 Objective-C 指针

    浅谈 Swift 2 中的 Objective-C 指针 2015-09-07  499 文章目录 1. 在 Swift 中读 C 指针 2. 在 Swift 中创建 C 指针 3. 总结 作者:Ja ...

  7. c#Winform程序调用app.config文件配置数据库连接字符串 SQL Server文章目录 浅谈SQL Server中统计对于查询的影响 有关索引的DMV SQL Server中的执行引擎入门 【译】表变量和临时表的比较 对于表列数据类型选择的一点思考 SQL Server复制入门(一)----复制简介 操作系统中的进程与线程

    c#Winform程序调用app.config文件配置数据库连接字符串 你新建winform项目的时候,会有一个app.config的配置文件,写在里面的<connectionStrings n ...

  8. 你真的懂Flask中浅谈蓝图Blueprint吗?

    一,什么是Flask中的蓝图Blueprint Blueprint是用于实现Flask框架中单个应用的视图,模板,静态文件的集合. Blueprint 是一个存储操作(路由映射)方法的容器,这些操作在 ...

  9. 浅谈人脸识别中的loss 损失函数

    浅谈人脸识别中的loss 损失函数 2019-04-17 17:57:33 liguiyuan112 阅读数 641更多 分类专栏: AI 人脸识别   版权声明:本文为博主原创文章,遵循CC 4.0 ...

随机推荐

  1. 百度EasyDL文本分类自定义API示例代码 python

    因为需要将命名实体中的组织机构名进一步区分为政府.企业.社会组织等,在easydl上做了一个文本分类模型,但是要用这个接口时候发现, 官方文档中竟然还在用urllib2的库,且不完整.好多地方会报错, ...

  2. zzw_非root用户安装python3.5

    目的:不想改变linux 自带的python,只想要用特定的非root用户运行特定版本的python 1.进入非root用户 2.新建一个python3.5的安装目录 [a4_csbdc@bdc816 ...

  3. 跟随我在oracle学习php(11)

    数组专题 数组遍历: 1,普通for循环,经常用的数组遍历 var arr = [1,2,0,3,9]; for ( var i = 0; i <arr.length; i++){ consol ...

  4. JavaWeb+SVN+Maven+Tomcat +jenkins实现自动化部署

    网址:https://blog.csdn.net/liyong1028826685/article/details/88289218 在日常开发项目中常见的开发模式是使用代码库来存放我们的项目例如:S ...

  5. WPF拖动总结

    https://www.cnblogs.com/DebugLZQ/archive/2013/05/07/3062733.html <Window xmlns="http://schem ...

  6. python学习------文件处理

    文件操作 一 介绍 计算机系统分为:计算机硬件,操作系统,应用程序三部分. 我们用python或其他语言编写的应用程序若想要把数据永久保存下来,必须要保存于硬盘中,这就涉及到应用程序要操作硬件,众所周 ...

  7. python学习1-1

    # 可以支持多个用户登录 (提示,通过列表存多个账户信息) uname = ['wps', 'opp' ] pword = ['] time = 0 while time < 3: u_name ...

  8. Idea中:No converter found for return value of type: class java.util.ArrayList:Json格式转换问题

    1.在搞SSM框架的时候,前端发送请求后,显示如下错误. @ResponseBody注解进行返回List<对象>的json数据时出现 nested exception is java.la ...

  9. 安装CaffeOnSpark过程中遇到的问题及解决方案

    安装教程来自 http://blog.csdn.net/sadonmyown/article/details/72781393 首先,我使用的节点环境是ubuntu 16.04.1,事先 成功安装了s ...

  10. java 的重写(覆盖) 和重载的区别

    方法的的重写(覆盖) 在类继承中,子类可以修改从父类继承来的行为,也就是说子类能创建一个与父类方法有不同功能的方法,但具有相同的:名称.返回类型.参数列表.如果在子类中定义一个方法,其方法名称.返回值 ...