Java: Math

Math.max(5, 10);    // Outputs 10
Math.min(5, 10);    // Outputs 5
Math.sqrt(64);    // Outputs 8.0
Math.abs(-4.7);    // Outputs 4.7
Math.random();    // returns a random number between 0.0 (inclusive), and 1.0 (exclusive)
(int)(Math.random() * 101);  // 0 to 100

 

posted @ 2022-11-24 03:28  小白冲冲  阅读(22)  评论(0)    收藏  举报