Guest User

Untitled

a guest
Jan 18th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. public static String parseScientificNotation(double value) {
  2. String result;
  3.  
  4. String stringValue = Double.toString(value).toLowerCase();
  5.  
  6. if (stringValue.contains("e-")) {
  7. String[] arr = stringValue.split("e-");
  8. try {
  9. int precision = Integer.parseInt(arr[1]);
  10. result = String.format("%." + precision + "f", value);
  11. } catch (NumberFormatException nfe) {
  12. nfe.printStackTrace();
  13. result = stringValue;
  14. }
  15. } else {
  16. result = stringValue;
  17. }
  18.  
  19. return result;
  20. }
Add Comment
Please, Sign In to add comment