work to make documentation unified.

This commit is contained in:
Olivier Gagnon
2021-03-12 02:51:56 -05:00
parent a00c253dcb
commit 2ce6ff2041
176 changed files with 1325 additions and 916 deletions

View File

@@ -3,18 +3,20 @@ nFormat() Netscript Function
.. js:function:: nFormat(n, format)
:param number n: Number to format
:param string format: Formatter
:RAM cost: 0 GB
:param number n: number to format
:param string format: The format to use.
Converts a number into a string with the specified formatter. This uses the
`numeraljs <http://numeraljs.com/>`_ library, so the formatters must be compatible
with that.
Converts a number into a string with the specified format. This uses the
`numeraljs <http://numeraljs.com/>`_ library, so the formatters must be
compatible with that.
This is the same function that the game itself uses to display numbers.
The game uses the ``$0.000a`` format to display money.
Examples::
Example:
nFormat(1.23e9, "$0.000a"); // Returns "$1.230b"
nFormat(12345.678, "0,0"); // Returns "12,346"
nFormat(0.84, "0.0%"); // Returns "84.0%
.. code-block:: javascript
nFormat(1.23e9, "$0.000a"); // returns: "$1.230b"
nFormat(12345.678, "0,0"); // returns: "12,346"
nFormat(0.84, "0.0%"); // returns: "84.0%"