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)
| 510 | * @return A String. |
| 511 | */ |
| 512 | static protected String doubleToString(double d) { |
| 513 | if (Double.isInfinite(d) || Double.isNaN(d)) { |
| 514 | return "null"; |
| 515 | } |
| 516 | |
| 517 | // Shave off trailing zeros and decimal point, if possible. |
| 518 | |
| 519 | String string = Double.toString(d); |
| 520 | if (string.indexOf('.') > 0 && string.indexOf('e') < 0 && |
| 521 | string.indexOf('E') < 0) { |
| 522 | while (string.endsWith("0")) { |
| 523 | string = string.substring(0, string.length() - 1); |
| 524 | } |
| 525 | if (string.endsWith(".")) { |
| 526 | string = string.substring(0, string.length() - 1); |
| 527 | } |
| 528 | } |
| 529 | return string; |
| 530 | } |
| 531 | |
| 532 | |
| 533 | /** |