您的位置:首页 > 编程语言 > Java开发

java math常用函数

2017-01-29 18:31 267 查看
package com.releed.hellojava;

public class HelloJava {
//类名首字母一般大写
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("10+5="+(10+5));
System.out.println("10-5="+(10-5));
System.out.println("10*5="+10*5);
System.out.println("10/3="+10.0/3);
System.out.println("10/3="+Math.floor(10.0/3));
System.out.println("3.75四舍五入="+Math.round(3.75));
System.out.println("3.75四舍五入保留一位小数="+Math.round(3.75*10)/10.0);
//3.75*10为37.5 round四舍五入后为38
//之后结果再/10.0=3.8
System.out.println("|-10|="+Math.abs(-10));
System.out.println("2的8次方="+Math.pow(2, 8));
System.out.println("100的平方根="+Math.sqrt(100));
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: