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:
26
doc/source/netscript/basicfunctions/formatRam.rst
Normal file
26
doc/source/netscript/basicfunctions/formatRam.rst
Normal file
@@ -0,0 +1,26 @@
|
||||
formatRam() Netscript Function
|
||||
==============================
|
||||
|
||||
.. js:function:: formatRam(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 ram 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.formatRam(number)); //1.23GB or 1.23GiB
|
||||
ns.print(ns.formatRam(number,0)); //1GB or 1GiB
|
||||
ns.print(ns.formatRam(number,3)); //1.235GB or 1.235GiB
|
||||
ns.print(ns.formatRam(2**12,3)); //4.096tB or 4tiB
|
||||
ns.print(ns.formatRam(2**20,3)); //1.049PB or 1PiB
|
||||
Reference in New Issue
Block a user