java math.round
时间: 2023-08-24 22:07:13 浏览: 101
详解Java中Math.round()的取整规则
The Java Math.round() method is used to round off a decimal value to the nearest integer. The method takes a single argument, which is the decimal value that needs to be rounded off.
Syntax:
```
public static long round(double value)
```
Example:
```
double num = 3.45;
long roundedNum = Math.round(num);
System.out.println(roundedNum); // Output: 3
```
In the above example, the Math.round() method is used to round off the decimal value 3.45 to the nearest integer, which is 3. The output is then printed to the console.
阅读全文