Skip to content

Number formatting functions? #669

Answered by sharkdp
qrilka asked this question in Q&A
Discussion options

You must be logged in to vote

We currently lack some proper functionality for formatting Numbers. See also this ticket: #219

One workaround to do this right now is to format it as a string. For example:

>>> let x = 1e20
>>> x

    = 1.0e+20

>>> "{x:.0}"

    = "100000000000000000000"    [String]

You could even make a function out of this and add it to your init.nbt file:

fn format_normal(q) = "{q:.0}"

Then you do something like

>>> x -> format_normal

    = "100000000000000000000"    [String]

That said, it's still just a workaround. We should support this natively. Please feel free to comment in the linked ticket if you have additional ideas or like to contribute in another way.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by qrilka
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants