processing/processing-docs

Update nf() page to indicate show righthand-only formatting

Closed this issue · 0 comments

Issue description

Currently, nf() can be used for standard righthand-only formatting to limit decimal / floating point precision -- e.g.

println(nf(1.23456, 0, 3)); // prints 1.235

Despite this being one of the most common forms of number formatting, this usage is not shown on the nf reference page, confusing people who are looking for it. In fact, the reference suggests that 0 is not a valid value for the left argument, saying:

"The values for the digits, left, and right parameters should always be positive integers."

...which is not true.

As a result, over the years, the question of how to do this comes up over and over on the forums -- and people sometimes develop unneeded elaborate workarounds.

URL(s) of affected page(s)

https://processing.org/reference/nf_.html

Proposed fix

Update the page with an example and correct the argument text.