zoukankan      html  css  js  c++  java
  • java Math.round()

    public class MathTest {
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		//Math.round():四舍五入运算
    		System.out.println("1.小数点后第一位  =5");
    		System.out.println("正数:Math.round(11.5) = " + Math.round(11.5));
    		System.out.println("负数:Math.round(-11.5) = " + Math.round(-11.5));
    		
    		System.out.println("2.小数点后第一位  <5");
    		System.out.println("正数:Math.round(11.49) = " + Math.round(11.49));
    		System.out.println("负数:Math.round(-11.49) = " + Math.round(-11.49));
    		
    		System.out.println("3.小数点后第一位  >5");
    		System.out.println("正数:Math.round(11.69) = " + Math.round(11.69));
    		System.out.println("负数:Math.round(-11.61) = " + Math.round(-11.69));
    		
    		System.out.println("总结:正数小数点后大于5则舍入,负数小数点后小于以及等于5都舍去,反之舍入");
    		System.out.println("也就是说:小数点后大于5全部加,等于5正数加,小于5全不加");
    	}
    

      


  • 相关阅读:
    自动轮播
    哈夫曼树的应用-金条划分
    计算两个日期相差的天数
    数据结构之算术表达式
    动态规划-矩阵最短路径
    动态规划-换钱最少货币数
    字母数字密码破解
    荷兰国旗问题
    集合并集
    进制数位幸运数
  • 原文地址:https://www.cnblogs.com/bluestorm/p/2298123.html
Copyright © 2011-2022 走看看