mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-18 07:18:38 +02:00
doc function updates and additions (#387)
This commit is contained in:
23
doc/source/netscript/basicfunctions/formatPercent.rst
Normal file
23
doc/source/netscript/basicfunctions/formatPercent.rst
Normal file
@@ -0,0 +1,23 @@
|
||||
formatPercent() Netscript Function
|
||||
==============================
|
||||
|
||||
.. js:function:: formatPercent(number[, fractionalDigits = 2])
|
||||
|
||||
:RAM cost: 0 GB
|
||||
|
||||
:param number number: Number to format.
|
||||
:param number fractionalDigits: Number of digits to show in the fractional part of the decimal number.
|
||||
|
||||
:returns: Formatted string.
|
||||
|
||||
Converts a number into a string with percent formatting.
|
||||
|
||||
The format depends on the Numeric Display settings (all options on the "Numeric Display" options page).
|
||||
|
||||
Examples:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
const number = 1.23456789
|
||||
ns.print(ns.formatPercent(number)); //123.46%
|
||||
ns.print(ns.formatPercent(number,4)); //123.4568%
|
||||
Reference in New Issue
Block a user