2019-03-03 04:08:54 +01:00
|
|
|
nFormat() Netscript Function
|
|
|
|
============================
|
|
|
|
|
|
|
|
.. js:function:: nFormat(n, format)
|
|
|
|
|
2021-03-07 10:13:37 +01:00
|
|
|
:RAM cost: 0 GB
|
2021-03-12 08:51:56 +01:00
|
|
|
:param number n: number to format
|
|
|
|
:param string format: The format to use.
|
2019-03-03 04:08:54 +01:00
|
|
|
|
2021-03-12 08:51:56 +01:00
|
|
|
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.
|
2019-03-03 04:08:54 +01:00
|
|
|
|
2021-03-12 08:51:56 +01:00
|
|
|
The game uses the ``$0.000a`` format to display money.
|
2019-03-03 04:08:54 +01:00
|
|
|
|
2021-03-12 08:51:56 +01:00
|
|
|
Example:
|
2019-03-03 04:08:54 +01:00
|
|
|
|
2021-03-12 08:51:56 +01:00
|
|
|
.. 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%"
|