标签:http 输出 == pre https strong tar === ati
代码如下,后面的注释是输出的结果
public static void main(String[] args) { System.out.println(Math.round(0.399));//0 System.out.println(Math.round(0.4));//0 System.out.println(Math.round(0.41));//0 System.out.println(Math.round(0.499));//0 System.out.println(Math.round(0.5));//1 System.out.println(Math.round(0.51));//1 System.out.println(Math.round(0.6));//1 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));//0 System.out.println(Math.round(-0.499));//0 System.out.println(Math.round(-0.41));//0 System.out.println(Math.round(-0.4));//0 System.out.println(Math.round(-0.399));//0 }
总结,round的进位是向数轴的右方向进位的,而不是按照数的绝对值进行四舍五入的
关于Math对三角函数表示的一些知识点查看https://blog.csdn.net/River_Continent/article/details/80637952
标签:http 输出 == pre https strong tar === ati
原文地址:https://www.cnblogs.com/kitor/p/11320302.html