The nfp() function in p5.js is used to format the input numbers (integers or floats) into strings as well as it gives positive (+) and negative (-) sign according to the sign of input numbers.
nfp(Num, Left, Right)
Parameters: This function accepts three parameters as mentioned above and described below:
- Num: This is the input positive number or an array of numbers which are to be formatted.
- Left: This is the positive number which says the number of digits should be on the left side of the decimal point.
- Right: This is the positive number which says the number of digits should be on the right side of the decimal point.
Return Value: It returns the formatted string.
Below programs illustrate the nfp() function in p5.js:
Example 1: This example uses nfp() function to format the input numbers.
Example 2: This example uses nfp() function to format the input numbers.
- How to get the function name inside a function in PHP ?
- p5.js | sin() function
- p5.js | cos() function
- p5.js | log() function
- PHP | each() Function
- p5.js | arc() Function
- p5.js | tan() function
- p5.js | box() Function
- p5.js | nfs() Function
- p5.js | max() function
- PHP | Ds\Set contains() Function
- D3.js | d3.min() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.