MCPcopy Index your code
hub / github.com/processing/processing / numberToString

Method numberToString

core/src/processing/data/JSONObject.java:982–1001  ·  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

980 * @throws RuntimeException If number is null or a non-finite number.
981 */
982 private static String numberToString(Number number) {
983 if (number == null) {
984 throw new RuntimeException("Null pointer");
985 }
986 testValidity(number);
987
988 // Shave off trailing zeros and decimal point, if possible.
989
990 String string = number.toString();
991 if (string.indexOf('.') > 0 && string.indexOf('e') < 0 &&
992 string.indexOf('E') < 0) {
993 while (string.endsWith("0")) {
994 string = string.substring(0, string.length() - 1);
995 }
996 if (string.endsWith(".")) {
997 string = string.substring(0, string.length() - 1);
998 }
999 }
1000 return string;
1001 }
1002
1003
1004 /**

Callers 2

valueToStringMethod · 0.95
writeValueMethod · 0.95

Calls 2

testValidityMethod · 0.95
toStringMethod · 0.45

Tested by

no test coverage detected