Produce a string from a double. The string "null" will be returned if the number is not finite. @param d A double. @return A String.
(double d)
| 523 | * @return A String. |
| 524 | */ |
| 525 | static protected String doubleToString(double d) { |
| 526 | if (Double.isInfinite(d) || Double.isNaN(d)) { |
| 527 | return "null"; |
| 528 | } |
| 529 | |
| 530 | // Shave off trailing zeros and decimal point, if possible. |
| 531 | |
| 532 | String string = Double.toString(d); |
| 533 | if (string.indexOf('.') > 0 && string.indexOf('e') < 0 && |
| 534 | string.indexOf('E') < 0) { |
| 535 | while (string.endsWith("0")) { |
| 536 | string = string.substring(0, string.length() - 1); |
| 537 | } |
| 538 | if (string.endsWith(".")) { |
| 539 | string = string.substring(0, string.length() - 1); |
| 540 | } |
| 541 | } |
| 542 | return string; |
| 543 | } |
| 544 | |
| 545 | |
| 546 | /** |