BigDecimal.ROUND_FLOOR
时间: 2023-09-27 18:05:27 浏览: 138
BigDecimal的用法
ROUND_FLOOR is a rounding mode constant in the BigDecimal class in Java. It represents rounding towards negative infinity. When the ROUND_FLOOR mode is used, the value will be rounded down to the next whole number or the nearest lower value.
Here's an example of how to use ROUND_FLOOR with BigDecimal in Java:
```java
import java.math.BigDecimal;
import java.math.RoundingMode;
public class Main {
public static void main(String[] args) {
BigDecimal value = new BigDecimal("3.14159");
BigDecimal roundedValue = value.setScale(2, RoundingMode.FLOOR);
System.out.println("Rounded value: " + roundedValue);
}
}
```
Output:
Rounded value: 3.14
In this example, the value 3.14159 is rounded down to 3.14 using the ROUND_FLOOR mode.
阅读全文