Java Decimal Format getStandardDeviationString(double[] standardDeviationDoubles)

Here you can find the source of getStandardDeviationString(double[] standardDeviationDoubles)

Description

get Standard Deviation String

License

Apache License

Declaration

public static String getStandardDeviationString(double[] standardDeviationDoubles) 

Method Source Code


//package com.java2s;
/*// w w  w.jav a2s.c  o  m
 * Copyright 2015 Red Hat, Inc. and/or its affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.text.DecimalFormat;

public class Main {
    public static String getStandardDeviationString(double[] standardDeviationDoubles) {
        if (standardDeviationDoubles == null) {
            return null;
        }
        StringBuilder standardDeviationString = new StringBuilder(standardDeviationDoubles.length * 9);
        // Abbreviate to 2 decimals
        // We don't use a local sensitive DecimalFormat, because other Scores don't use it either (see PLANNER-169)
        DecimalFormat exponentialFormat = new DecimalFormat("0.0#E0");
        DecimalFormat decimalFormat = new DecimalFormat("0.0#");
        boolean first = true;
        for (double standardDeviationDouble : standardDeviationDoubles) {
            if (first) {
                first = false;
            } else {
                standardDeviationString.append("/");
            }
            // See http://docs.oracle.com/javase/7/docs/api/java/lang/Double.html#toString%28double%29
            String abbreviated;
            if (0.001 <= standardDeviationDouble && standardDeviationDouble <= 10000000.0) {
                abbreviated = decimalFormat.format(standardDeviationDouble);
            } else {
                abbreviated = exponentialFormat.format(standardDeviationDouble);
            }
            standardDeviationString.append(abbreviated);
        }
        return standardDeviationString.toString();
    }
}

Related

  1. getProgressExact(double balance, double cost)
  2. getRealEye(double eye)
  3. getRedondeoHaciaArriba(double pTotal)
  4. getScientificNotation(double value)
  5. getSpaceMessage(final double bytes)
  6. getStandardDouble(double d, int pL)
  7. getString(Double d)
  8. getStringFromDouble(double number)
  9. getStringRepresentationForDouble(double value)