Here you can find the source of getEngineeringNotation(final double d)
Parameter | Description |
---|---|
d | a parameter |
public static String getEngineeringNotation(final double d)
//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; } }