processing / processing/processing-website

nf() function description inadequate

Open
#353 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
MDX
Stars
90
Forks
122
Avg merge
1h 43m
Merged PRs (30d)
3

Description

Issue description

nf() function reference could use a better description. As of now the text says:

Utility function for formatting numbers into strings. There are two versions: one for formatting floats, and one for formatting ints. The values for the digits and right parameters should always be positive integers. The left parameter should be positive or 0. If it is zero, only the right side is formatted.

This text only states that an int and a float version is existent. Nowhere is it explained how those are different. Referring to this description a call like nf(float, int) would be valid. This call however is not functional as passing num as a float variable requires to specify a left and right parameter (so the call has to be nf(float, int, int)).

This could be confusing to beginner programmers.

URL(s) of affected page(s)

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

Proposed fix

In my opinion ideally, in line with single responsibility, these would be two functions.

However an extended description should also do the trick.
The text could be extended by a paragraph similar to:

When num is a variable of type float the call becomes nf(num, left, right). left represents the formatted number left of the decimal point and right represents the formatting right of the decimal point.

Alternatively it could be made clear in the Syntax and Parameter section which call allows which parameters.

nf(numf, left, right)
nf(numsf, left, right)

numf = float: the number to format
numsf = float[]: the numbers to format

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open the affected nf() reference page at processing.org/reference/nf_.html and review its current description, Syntax, and Parameter sections. Clarify the different call forms and required parameters for float and array inputs. The work is done when a beginner can tell which signature applies to each input type.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.