代码如下,后面的注释是输出的结果

public static void main(String[] args) {
System.out.println(Math.round(0.399));//
System.out.println(Math.round(0.4));//
System.out.println(Math.round(0.41));//
System.out.println(Math.round(0.499));//
System.out.println(Math.round(0.5));//
System.out.println(Math.round(0.51));//
System.out.println(Math.round(0.6));//
System.out.println("======================");
System.out.println(Math.round(-0.6));//-1
System.out.println(Math.round(-0.51));//-1
System.out.println(Math.round(-0.5));//
System.out.println(Math.round(-0.499));//
System.out.println(Math.round(-0.41));//
System.out.println(Math.round(-0.4));//
System.out.println(Math.round(-0.399));//
}

 总结,round的进位是向数轴的右方向进位的,而不是按照数的绝对值进行四舍五入的

关于Math对三角函数表示的一些知识点查看https://blog.csdn.net/River_Continent/article/details/80637952

Math的round方法的更多相关文章

  1. JS Math.round()方法原理

    请先测试代码: <!doctype html> <html lang="en"> <head> <meta charset="U ...

  2. C#中,使用显式类型转换(int)和Math.Round方法,将浮点数转换为整数的区别

    主要区别就是,显式类型转换(int)是将浮点数的整数部分截取出来,然后转换为整数,所以相当于是向下取整.而Math.Round方法是对浮点数进行四舍五入后,转换为整数. 新建一个.NET Core控制 ...

  3. 【转载】 C#使用Math.Round方法对计算结果进行四舍五入操作

    在C#的数值运算中,有时候需要对计算结果进行四舍五入操作,此时就可使用内置方法Math.Round方法来实现四舍五入操作,Math.Round方法有多个重载函数,支持设置有效位数进行四舍五入,如果没有 ...

  4. JS对象 四舍五入round() round() 方法可把一个数字四舍五入为最接近的整数。 语法: Math.round(x)

    四舍五入round() round() 方法可把一个数字四舍五入为最接近的整数. 语法: Math.round(x) 参数说明: 注意: 1. 返回与 x 最接近的整数. 2. 对于 0.5,该方法将 ...

  5. Math.round方法、String实例化

    math.round(11.5)==12 传入的值是11.5,通过math.round方法进行四舍五入变成12(把一个数字舍入为最接近的整数) string s = new string("xyz") ...

  6. JavaScript中Math对象的方法介绍

    1.比较最值方法 比较最值有两种方法,max() 和 min() 方法. 1.1 max() 方法,比较一组数值中的最大值,返回最大值. var maxnum = Math.max(12,6,43,5 ...

  7. Math 对象的方法

    Math 对象的方法 方法 描述 abs(x) 返回数的绝对值 acos(x) 返回数的反余弦值 asin(x) 返回数的反正弦值 atan(x) 以介于 -PI/2 与 PI/2 弧度之间的数值来返 ...

  8. Java重写round()方法

    题目:完毕这种方法的代码实现 public static String round (String arg1, int arg2) 參数 arg1:表示等待被处理的数据:如:"100.286 ...

  9. javascript常用的Math对象的方法

    简介 Math对象是在程序编程中用于执行一些数学任务的.Math 对象并不像 Date 和 String 那样是对象的类,因此没有构造函数 Math(),像 Math.sin() 这样的函数只是函数, ...

随机推荐

  1. main 函数返回值

    [1]main函数 [2]main() 经典的C风格函数头,如下: main() 在C语言中,省略返回类型相当于说函数的类型为int. 但是,需要明确,C++逐步淘汰了这种用法. 另外,在C语言中,让 ...

  2. Mysql系列(十一)—— 性能分析慢查询日志

    转载自:http://www.cnblogs.com/kerrycode/p/5593204.html 慢查询日志概念 MySQL的慢查询日志是MySQL提供的一种日志记录,它用来记录在MySQL中响 ...

  3. 深入V8引擎-写在前面

    这一篇不打算讲技术,聊点别的吧,写这个的原因主要是看到了我博客园的签名,开始这个最终源码系列前想说点什么. 转行前端(达成) 入行1年vue源码(达成).webpack源码(半达成) 入行2年争取读通 ...

  4. [转] Performance_js中计算网站性能监控利器

    1.Performance方法 Performance提供的方法可以灵活使用,获取到页面加载等标记的耗时情况. performance.now() //返回当前到页面打开时刻的耗时,精确到千分之一毫秒 ...

  5. WPF 精修篇 事件触发器

    原文:WPF 精修篇 事件触发器 事件触发器 一般使用的就是动画 <Grid> <TextBlock Text="事件触发器" Opacity="0.2 ...

  6. vscode 代码折叠快捷键,折叠所有/展开所有

    1.折叠所有区域的快捷键:ctrl + k   ctrl + 0 (这里是数字键0) 2.展开所有区域的快捷键:ctrl + j    ctrl + j

  7. linux centos无法删除网站根目录下的.user.ini解决办法

    .user.ini文件在执行rm -rf时,提示无法删除 解决办法 首先了解下chattr命令的作用:不让用户修改.删除文件等. -i选项:设定文件不能被删除.改名.设定链接关系,同时不能写入或新增内 ...

  8. vue 强制刷新 demo 神器

    this.$forceUpdate() /*关键句,强制更新dom*/

  9. ES6 入门系列 (一)ES6的前世今生

    要学好javascript , ECMAScript标准比什么都强, ESMAScript标准已经用最严谨的语言和最完美的角度展现了语言的实质和特性. 理解语言的本质后,你已经从沙堆里挑出了珍珠,能经 ...

  10. ffmpeg 基本数据结构和对象(一): AVPacket、AVPicture、AVFrame

    来源:http://blog.csdn.net/chance_yin/article/details/16817957 一.AVPacket /** * AVPacket 作为解码器的输入 或 编码器 ...