1 /*******************************************************************************
\r
2 * Copyright (c) 2010 Association for Decentralized Information Management in
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.databoard.units.internal.deprecated;
14 public enum Magnitude {
16 yotta("Y", 24, "yotta"),
17 zetta("Z", 21, "zetta"),
19 peta("P", 15, "peta"),
20 tera("T", 12, "tera"),
24 hecto("h", 2, "hecto"),
25 deca("da", 1, "deca"),
27 deci("d", -1, "deci"),
28 centi("c", -2, "centi"),
29 milli("m", -3, "milli"),
30 micro("ยต", -6, "micro"),
31 nano("n", -9, "nano"),
32 pico("p", -12, "pico"),
33 femto("f", -15, "femto"),
34 atto("a", -18, "atto"),
35 zepto("z", -21, "zepto"),
36 yocto("y", -24, "yocto")
43 private Magnitude(String symbol, int exp, String prefix) {
49 public String getPrefix() {
54 public String toString() {
58 public int getExponent() {
63 * Get most suitable magnitude for a value
66 * @return suitable magnitude
68 public static Magnitude getSuitable(double value)
70 double exp = Math.log10(value);
71 for (Magnitude m : values()) {
72 if (m.equals(hecto)||m.equals(deca)) continue;