Java Decimal Format getEngineeringNotation(final double d)

Here you can find the source of getEngineeringNotation(final double d)

Description

get Engineering Notation

License

Open Source License

Parameter

Parameter Description
d a parameter

Return

String

Declaration

public static String getEngineeringNotation(final double d) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Manchester Centre for Integrative Systems Biology
 * University of Manchester//  w ww. jav  a2s . c  o  m
 * Manchester M1 7ND
 * United Kingdom
 * 
 * Copyright (C) 2007 University of Manchester
 * 
 * This program is released under the Academic Free License ("AFL") v3.0.
 * (http://www.opensource.org/licenses/academic.php)
 *******************************************************************************/

import java.text.*;

public class Main {
    /**
     * 
     */
    private final static String E0 = "E0";
    /**
     * 
     */
    private final static NumberFormat engineeringFormat = new DecimalFormat("##0.#E0");

    /**
     * 
     * @param d
     * @return String
     */
    public static String getEngineeringNotation(final double d) {
        final String engineeringNotation = engineeringFormat.format(d);

        if (engineeringNotation.endsWith(E0)) {
            return engineeringNotation.substring(0, engineeringNotation.length() - E0.length());
        }

        return engineeringNotation;
    }
}

Related

  1. getDoubledigit(double f)
  2. getDoubleForDisplay(Double d)
  3. getDoubleFromTaxSet(String taxSetValue)
  4. getDoubleWithTwoDecimalDigits(double value)
  5. getDurationString(double duration)
  6. getInteger(Double d)
  7. getIntNum(Double value)
  8. getProgressExact(double balance, double cost)
  9. getRealEye(double eye)