How to print with 2 decimals?

Hello.
I need to print a float variable with 2 decimals. I couldn’t find on processing reference :expressionless:

1 Like

with the
https://processing.org/reference/nf_.html
can say how many decimals you want show in a string

println( nf( 0.1234567,0,2) );
2 Likes

Not your fault – the reference documentation for nf is actually misleading here.

For further examples and past discussion, also see:

1 Like

…proposed an update to the reference to help answer this perennial question.

3 Likes

and for the reference page i have 2 more ideas

-a- i like the header menu from the
https://p5js.org/reference/
so you could just jump directly to the “String Functions” group.

-b- HTML has some more features now,
how about show some “tool tip” when you are over the link?

because, if you NOT know the command nf()

  • how can you find it
  • why you should click on it.
1 Like