bitburner-src/markdown/bitburner.ns.getpurchasedservercost.md
2023-04-28 14:45:55 -04:00

981 B

Home > bitburner > NS > getPurchasedServerCost

NS.getPurchasedServerCost() method

Get cost of purchasing a server.

Signature:

getPurchasedServerCost(ram: number): number;

Parameters

Parameter Type Description
ram number Amount of RAM of a potential purchased server, in GB. Must be a power of 2 (2, 4, 8, 16, etc.). Maximum value of 1048576 (2^20).

Returns:

number

The cost to purchase a server with the specified amount of ram.

Remarks

RAM cost: 0.25 GB

Returns the cost to purchase a server with the specified amount of ram.

Example

const ram = 2 ** 20;
const cost = ns.getPurchasedServerCost(ram);
ns.tprint(`A purchased server with ${ns.formatRam(ram)} costs ${ns.formatMoney(cost)}`);