[][src]Static p5_sys::global::nfc

pub static nfc: NfcInternalType

Utility function for formatting numbers into strings and placing appropriate commas to mark units of 1000. There are two versions: one for formatting ints, and one for formatting an array of ints. The value for the right parameter should always be a positive integer.

Examples

function setup() {
  background(200);
  let num = 11253106.115;
  let numArr = [1, 1, 2];

  noStroke();
  fill(0);
  textSize(12);

  // Draw formatted numbers
  text(nfc(num, 4), 10, 30);
  text(nfc(numArr, 2), 10, 80);

  // Draw dividing line
  stroke(120);
  line(0, 50, width, 50);
}

Overloads

num the Number to format

right? number of digits to the right of the decimal point


nums the Numbers to format

right? number of digits to the right of the decimal point