A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© funny 中级黑马   /  2015-9-9 23:14  /  306 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

package com.wf.dao;

public class A {

        /**
         * @param args
         */
        public static void main(String[] args) {
                // abs 取绝对值
                System.out.println(Math.abs(-13));

                // ceil天花板
                System.out.println(Math.ceil(12.2));                         // 13.0
                System.out.println(Math.ceil(12.9));                         // 13.0

                // floor 地板
                System.out.println(Math.floor(12.9));                 // 12.0
                System.out.println(Math.floor(12.1));                 // 12.0
               
                //pow()    2^10=1024
                System.out.println(Math.pow(2, 10));                        //1024.0
               
                //生成0.0到1.0之间的所以小数,包括0.0,不包括1.0
                System.out.println(Math.random());
               
                //四舍五入
                System.out.println(Math.round(12.9));                        //13   返回类型是int类型
                System.out.println(Math.round(12.1));                        //12
               
                //sqrt开平方
                System.out.println(Math.sqrt(4));                                        //2.0
                System.out.println(Math.sqrt(9));                                        //3.0
        }

}

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马