package com.gc.system;
public class Demo {
public static void main(String[] args) {
getFloorCeilRound();
getMinMax();
getRandomValue();
}
private static void getFloorCeilRound() {
double d = 12.51;
//小于的最大整数
double floor = Math.floor(d);
System.out.println(floor);//12.0
//大于的最小整数
double ceil = Math.ceil(d);
System.out.println(ceil);//13.0
//四舍五入
long round = Math.round(d);
System.out.println(round);//13
}
private static void getRandomValue() {
String rand = "";
for(int i=0;i<6;i++) {
//Math.floor() 取小于x的最大整数,得到0-9的范围 //Math.ceil() 1-10
double d = Math.floor(Math.random()*10);// 0-9.9999
rand += (int)d;
}
System.out.print(rand);
}
private static void getMinMax() {
int a = 10;
int b = 5;
int min = Math.min(a, b);
System.out.println(min);
int max = Math.max(a, b);
System.out.println(max);
}
}