Bitburner

Bitburner

View Stats:
Harry Jan 3, 2022 @ 8:52am
Formatting money?
Does anyone know how to format money more nicely instead of printing "50000000000" or even "5e10"? I would prefer reusing the numeralFormat (exporting numeralWrapper) class in the source code, but I do not know how to access it or import it.
(https://github.com/danielyxie/bitburner/blob/dev/src/ui/numeralFormat.ts)

I know I could probably just duplicate that code and the dependencies and make my own version based on that, but wanted to know if anyone figured out how to import this or solved money formatting already in an easy way.

Thanks in advance
Originally posted by Dolly ✨🌈🔧:
const formatted = ns.nFormat(myMoneyVariable, "$0.000a");

Hope that helps.
< >
Showing 1-4 of 4 comments
The author of this thread has indicated that this post answers the original topic.
Dolly ✨🌈🔧 Jan 3, 2022 @ 11:32am 
const formatted = ns.nFormat(myMoneyVariable, "$0.000a");

Hope that helps.
Harry Jan 3, 2022 @ 11:58am 
Originally posted by Dolly ✨🌈🔧:
const formatted = ns.nFormat(myMoneyVariable, "$0.000a");

Hope that helps.

Perfect, I somehow missed that. Thank you!
Dolly ✨🌈🔧 Jan 3, 2022 @ 12:39pm 
Glad to help!
matthallion May 9, 2024 @ 2:43pm 
the nFormat function is being replaced.

Format a number using the numeral library. This function is deprecated and will be removed in 2.4.

@deprecated — Use ns.formatNumber, formatRam, or formatPercent instead. Will be removed in 2.4.

@remarks — RAM cost: 0 GB

Converts a number into a string with the specified format options. See http://numeraljs.com/#format for documentation on format strings supported.
< >
Showing 1-4 of 4 comments
Per page: 1530 50