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全不加");
    	}
    

      


  • 相关阅读:
    Django Rest Framework 视图和路由
    DRF 权限 频率
    DRF 版本 认证
    Serializers 序列化组件
    学DRF之前
    RESTful
    windows下vmware配置nat网络
    python之路——网络编程
    图片上传
    数据库基本设计规范:
  • 原文地址:https://www.cnblogs.com/bluestorm/p/2298123.html
Copyright © 2011-2022 走看看