Here you can find the source of powerConverter(String _varSymbol)
Parameter | Description |
---|---|
_varSymbol | Name of the unit represented as String. |
public static int powerConverter(String _varSymbol)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w ww.j a v a 2s . c om * Converts a unit prefix to power of base 10. This method is probably obsolete since the introduction of the * new unit handling in the frontend. * TODO: Caution, this method is rather bad and relies on a pretty obsolete representation. * * @param _varSymbol Name of the unit represented as String. * @return Power of the prefix as int. */ public static int powerConverter(String _varSymbol) { if (_varSymbol == null || _varSymbol.length() < 2) { return 0; } if (_varSymbol.startsWith("d")) { return -1; } else if (_varSymbol.startsWith("c")) { return -2; } else if (_varSymbol.startsWith("m") && _varSymbol.length() > 1) {// in order to avoid confusion between meter and mili return -3; } else if (_varSymbol.startsWith("mu")) { return -6; } else if (_varSymbol.startsWith("n")) { return -9; } else if (_varSymbol.startsWith("p")) { return -12; } else if (_varSymbol.startsWith("f")) { return -15; } else if (_varSymbol.startsWith("a")) { return -18; } //positive powers else if (_varSymbol.startsWith("da")) { return 1; } else if (_varSymbol.startsWith("h")) { return 2; } else if (_varSymbol.startsWith("k")) { return 3; } else if (_varSymbol.startsWith("M")) { return 6; } else if (_varSymbol.startsWith("G")) { return 9; } else if (_varSymbol.startsWith("T")) { return 12; } else if (_varSymbol.startsWith("P")) { return 15; } else if (_varSymbol.startsWith("E")) { return 18; } System.err.println(_varSymbol + " prefix not supported!"); return 1; } }