getMaximumSignificantDigits method

int getMaximumSignificantDigits()

Returns the maximum number of significant digits provided by this precision model. Intended for use by routines which need to print out decimal representations of precise values (such as {@link WKTWriter}).

This method would be more correctly called getMinimumDecimalPlaces, since it actually computes the number of decimal places that is required to correctly display the full precision of an ordinate value.

Since it is difficult to compute the required number of decimal places for scale factors which are not powers of 10, the algorithm uses a very rough approximation in this case. This has the side effect that for scale factors which are powers of 10 the value returned is 1 greater than the true value.

@return the maximum number of decimal places provided by this precision model

Implementation

int getMaximumSignificantDigits() {
  int maxSigDigits = 16;
  if (modelType == FLOATING) {
    maxSigDigits = 16;
  } else if (modelType == FIXED) {
    double n = math.log(getScale()) / math.log(10);
    maxSigDigits = 1 + n.ceil();
  }
  return maxSigDigits;
}