pub static nfp: NfpInternalTypeExpand description
Utility function for formatting numbers into strings. Similar to nf() but puts a "+" in front of positive numbers and a "-" in front of negative numbers. There are two versions: one for formatting floats, and one for formatting ints. The values for left, and right parameters should always be positive integers.
Examples
function setup() {
background(200);
let num1 = 11253106.115;
let num2 = -11253106.115;
noStroke();
fill(0);
textSize(12);
// Draw formatted numbers
text(nfp(num1, 4, 2), 10, 30);
text(nfp(num2, 4, 2), 10, 80);
// Draw dividing line
stroke(120);
line(0, 50, width, 50);
}Overloads
num the Number to format
left? number of digits to the left of the decimal
point
right? number of digits to the right of the
decimal point
nums the Numbers to format
left? number of digits to the left of the decimal
point
right? number of digits to the right of the
decimal point