q5play
    Preparing search index...

    Function nf

    • 📘 Number formatter, can be used to display a number as a string with a specified number of digits before and after the decimal point, optionally adding padding with zeros.

      Parameters

      • num: number
      • digits: number

      Returns string

      a string representation of the number, formatted accordingly

      await Canvas(200, 100);
      background(0.8);

      textSize(32);
      text(nf(PI, 4, 5), -90, 10);
    • 🛠 nf is short for number format. It formats a number to a string with a specified number of digits.

      Parameters

      • num: number

        number to format

      • digits: number

        number of digits to format to

      Returns string

      formatted number

      await Canvas(200, 100);
      background(0.8);

      textSize(32);
      text(nf(PI, 4, 5), -90, 10);