@@ -9476,6 +9476,26 @@ static final public String[] str(float x[]) {
94769476
94779477 // INT NUMBER FORMATTING
94789478
9479+ static public String nf(float num) {
9480+ int inum = (int) num;
9481+ if (num == inum) {
9482+ return str(inum);
9483+ }
9484+ return str(num);
9485+ }
9486+
9487+ static public String[] nf(float[] nums) {
9488+ String[] outgoing = new String[nums.length];
9489+ for (int i = 0; i < nums.length; i++) {
9490+ outgoing[i] = nf(nums[i]);
9491+ }
9492+ return outgoing;
9493+ }
9494+
9495+ /**
9496+ * Integer number formatter.
9497+ */
9498+
94799499 static private NumberFormat int_nf;
94809500 static private int int_nf_digits;
94819501 static private boolean int_nf_commas;
@@ -9495,34 +9515,14 @@ static final public String[] str(float x[]) {
94959515 *
94969516 * ( end auto-generated )
94979517 * @webref data:string_functions
9498- * @param num the number to format
9518+ * @param nums the numbers to format
9519+ * @param digits number of digits to pad with zero
94999520 * @see PApplet#nfs(float, int, int)
95009521 * @see PApplet#nfp(float, int, int)
95019522 * @see PApplet#nfc(float, int)
95029523 * @see <a href="https://processing.org/reference/intconvert_.html">int(float)</a>
95039524 */
9504- static public String nf(float num) {
9505- int inum = (int) num;
9506- if (num == inum) {
9507- return str(inum);
9508- }
9509- return str(num);
9510- }
9511-
9512- /**
9513- * @param nums the numbers to format
9514- */
9515- static public String[] nf(int[] nums) {
9516- String[] outgoing = new String[nums.length];
9517- for (int i = 0; i < nums.length; i++) {
9518- outgoing[i] = nf(nums[i]);
9519- }
9520- return outgoing;
9521- }
95229525
9523- /**
9524- * @param digits number of digits to pad with zero
9525- */
95269526 static public String[] nf(int nums[], int digits) {
95279527 String formatted[] = new String[nums.length];
95289528 for (int i = 0; i < formatted.length; i++) {
@@ -9531,6 +9531,9 @@ static public String[] nf(int nums[], int digits) {
95319531 return formatted;
95329532 }
95339533
9534+ /**
9535+ * @param num the number to format
9536+ */
95349537 static public String nf(int num, int digits) {
95359538 if ((int_nf != null) &&
95369539 (int_nf_digits == digits) &&
@@ -9678,7 +9681,6 @@ static public String[] nfp(int nums[], int digits) {
96789681
96799682 // FLOAT NUMBER FORMATTING
96809683
9681-
96829684 static private NumberFormat float_nf;
96839685 static private int float_nf_left, float_nf_right;
96849686 static private boolean float_nf_commas;
0 commit comments