MCPcopy Index your code
hub / github.com/benfry/processing4 / numberToString

Method numberToString

core/src/processing/data/JSONObject.java:1024–1043  ·  view source on GitHub ↗

Produce a string from a Number. @param number A Number @return A String. @throws RuntimeException If number is null or a non-finite number.

(Number number)

Source from the content-addressed store, hash-verified

1022 * @throws RuntimeException If number is null or a non-finite number.
1023 */
1024 private static String numberToString(Number number) {
1025 if (number == null) {
1026 throw new RuntimeException("Null pointer");
1027 }
1028 testValidity(number);
1029
1030 // Shave off trailing zeros and decimal point, if possible.
1031
1032 String string = number.toString();
1033 if (string.indexOf('.') > 0 && string.indexOf('e') < 0 &&
1034 string.indexOf('E') < 0) {
1035 while (string.endsWith("0")) {
1036 string = string.substring(0, string.length() - 1);
1037 }
1038 if (string.endsWith(".")) {
1039 string = string.substring(0, string.length() - 1);
1040 }
1041 }
1042 return string;
1043 }
1044
1045
1046 /**

Callers 2

valueToStringMethod · 0.95
writeValueMethod · 0.95

Calls 2

testValidityMethod · 0.95
toStringMethod · 0.45

Tested by

no test coverage detected