Domanda

Directly from this API:

setMaximumIntegerDigits

public void setMaximumIntegerDigits(int newValue)

Sets the maximum number of digits allowed in the integer portion of a number. For formatting numbers other than BigInteger and BigDecimal objects, the lower of newValue and 309 is used. Negative input values are replaced with 0.

In this context, what does "the lower of newValue and 309 is used" mean? Considering that newValue is the int passed as an argument and 309 I have no idea what they are referring to.. Any clue would be appreciated. Thanks in advance.

È stato utile?

Soluzione

If you look in the source code for DecimalFormat you will find

// Upper limit on integer and fraction digits for a Java double
static final int DOUBLE_INTEGER_DIGITS  = 309;

It's the number of digits possible to represent before the decimal point in a Java double, insofar as the allowable range of a double is [-1.79769313486232e308 ; 1.79769313486232e308 ] (notice the exponents).

Cheers,

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top