我们如何设置 BigDecimal 的分辨率,使其只能采用以指定增量到达的值?

How can we set the resolution of a BigDecimal so it can only ever take values that land in specified increments?

是否可以设置 BigDecimal 的分辨率,例如到 10–9,因此值必须是该值的倍数且不能小于此值。

或者在通过舍入进行算术运算时必须这样做吗?

这就是我要找的东西

    BigDecimal val1 = new BigDecimal("1.00876876989",MathContext.DECIMAL128);

    // setting the scale to 10 sets the limits resolution, but the precision provided by the MathContext must be big enough to support this minimum resolution.
    // The rounding type doesn't matter but must be provided.

    val1 = val1.setScale(10, BigDecimal.ROUND_DOWN);