Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static String parseScientificNotation(double value) {
- String result;
- String stringValue = Double.toString(value).toLowerCase();
- if (stringValue.contains("e-")) {
- String[] arr = stringValue.split("e-");
- try {
- int precision = Integer.parseInt(arr[1]);
- result = String.format("%." + precision + "f", value);
- } catch (NumberFormatException nfe) {
- nfe.printStackTrace();
- result = stringValue;
- }
- } else {
- result = stringValue;
- }
- return result;
- }
Add Comment
Please, Sign In to add comment