Show given number of significant numbers of float in text()

Hi everyone. I want to show a float number in a text, but it show like 4 significant numbers.

float number = 1;
void setup()
{
  background(0);
  size(100,100);
}
void draw()
{
  fill(255);
  text(number,50,50);
  delay(500);
}

it show 4 zeros. but i want only 2 or 3 or what i want. How can i code that?

Sounds like you’re looking for the nf() function?

https://p5js.org/reference/#/p5/nf

Hello,

The Processing page has a list of references:
https://processing.org/reference/

The Processing PDE (IDE) also has a list of references; check out the tabs on top to find these.

Check out the ones in the Data > String Functions sections and choose wisely.

:)