1 package com.Date.Math;
2 /*
3 Math 数学类, 主要是提供了很多的数学公式。
4
5 abs(double a) 获取绝对值
6 ceil(double a) 向上取整
7 floor(double a) 向下取整
8 round(float a) 四舍五入
9 random() 产生一个随机数. 大于等于 0.0 且小于 1.0 的伪随机 double 值
10
11 */
12 public class Mathuse {
13
14 public static void main(String[] args) {
15
16 System.out.println("获取绝对值,"+Math.abs(3.14));
17
18 System.out.println("向上取整,"+Math.ceil(-3.14));
19
20 System.out.println("向下取整,"+Math.floor(3.14));
21
22 System.out.println("四舍五入,"+Math.round(3.56));
23
24 System.out.println("产生随机数,"+Math.random());
25
26 }
27
28 }