通过最近的学习,学到了一些的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. java的toString()及包装类的实现--Integer重点学习

    1. toString()来源 2. toString()目的 3. toString()实现(JDK8) 1. toString()来源 源于java.lang.Object类,源码如下: /** ...

  2. 小程序getLocation出现的各种问题汇总

    1.小程序无法弹出授权位置的弹框: 需要在app.json中增加相关配置文件: "permission": { "scope.userLocation": { ...

  3. A锚点实现,滚动页面内容改变tab选项

    Css: ul{margin:0;padding:0;list-style:none;} a{ text-decoration: none; outline:none; -webkit-tap-hig ...

  4. win7安装loadrunner 安装相关问题解决方案

    安装loadrunner缺少2.8 sp1组件解决方案 这是因为注册表缺少FullInstallVer和Version,归根到底是madc安装的的问题 以下是解决方法: 1.运行regedit,打开注 ...

  5. windows异步通知I/O模型

    回声服务器端: #include <stdio.h> #include <stdlib.h> #include <WinSock2.h> #define BUF_S ...

  6. Android中的Context(一)

    Android中的Context(一) 在Android开发中,Context可以说是我们接触地非常多的一个概念了,也译作"上下文",但是这个上下文到底是什么却并不好理解. 通俗的 ...

  7. 7ci

  8. js问题解决——cannot read property style of undefind

    当遇到cannot read property style of undefine的问题如下: 那就说明你设定的这个变量名为空 比如我在文档里写的属性名为list_box 但是我获取的属性名称写错了 ...

  9. wc.exe

    1 /* 2 * 没能实现的功能:wc.exe -s递归处理目录下符合条件的文件 3 * wc.exe -x 显示图形界面 4 * 5 * 6 * 实现的功能: wc.exe -c显示文件的字符数. ...

  10. 踩坑学习python自动化测试第二天!

    class put_out(object): def Helloword(str): print(str) Hello,Inder,Pist ="", [],{} word= st ...