Skip to content

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

@jeremydouglass

Description

@jeremydouglass

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions