# 30 common tools (2)

2020-12-07 14:41:14

Math Mathematical tools ( Method is a static method )

1 Rounding up ( Find a number larger than it recently ):ceil( The ceiling )

`````` System.out.println(Math.ceil(7.1));
// The return value is double type
``````

2 Rounding down ( Find the nearest number smaller than it ):floor( The floor )

`````` System.out.println(Math.floor(5.1));
// The return value is double type
``````

3 rounding :round

`````` System.out.print(Math.round(5.1));
System.out.print(Math.round(6.6));
// The return value is double type `
``````

4 0-1 Random number between ( decimal ):random

`````` System.out.print(Math.random());
// The return value is double type
``````

5 Maximum :max

`````` System.out.print(Math.max(5,1));
// The return value is the largest type of input arguments
``````

6 minimum value min

``````System.out.print(Math.min(5,33.4));
// The return value is the largest type of input arguments ( Such as int,double The return is double)
``````

7 n Of m Power

``````System.out.print(Math.pow(5,2));
// The formal parameter is double type , Yes, it's not double type , Because automatic type conversion
// The return value is double type
// Returns the value of the second power of the first parameter
``````

https://chowdera.com/2020/12/20201207143822301y.html