Pregunta

Directly from this java api

setMinimumFractionDigits

public void setMinimumFractionDigits(int newValue)

Sets the minimum number of digits allowed in the fraction portion of a number. minimumFractionDigits must be <= maximumFractionDigits. If the new value for minimumFractionDigits exceeds the current value of maximumFractionDigits, then maximumIntegerDigits will also be set to the new value.

What is the concern of maximumIntegerDigits with mimimumFractionDigits as specified in the above statement? (Exactly the following bit: "then maximumIntegerDigits will also be set to the new value"

¿Fue útil?

Solución

It just means that if you are setting the minimum to be a value larger than the maximum, that the maximum will be set to the minimum number. This way no constraint is broken. It would be strange to have a minimum larger than the maximum.

Example:

num.setMaximumFractionDigits(5);
num.setMinimumFractionDigits(8);
// the maximum is automatically set to 8

The line you specified is actually a javadoc typo, they meant maximiumFractionDigit, from OpenJDK

public void setMinimumFractionDigits(int newValue) {
    minimumFractionDigits = Math.max(0,newValue);
    if (maximumFractionDigits < minimumFractionDigits) {
        maximumFractionDigits = minimumFractionDigits;
    }
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top