Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Math/doc
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== precision_format == {{#invoke:math|precision_format|''value_string''|''precision''}} <syntaxhighlight lang="lua"> mm._precision_format(value_string, precision) </syntaxhighlight> Rounds a number to the specified precision and formats according to rules originally used for {{tl|Rnd}}. Output is a string. Parameter <var>precision</var> should be an integer number of digits after the decimal point. Negative values are permitted. Non-integers give unexpected results. Positive values greater than the input precision add zero-padding, negative values greater than the input order can consume all digits. Formatting 8,765.567 with {{tlc|#invoke:Math|precision_format|8765.567|<var>precision</var>}} gives: {|class="wikitable" |+ !<code><var>precision</var></code>!!Result |- |style="text-align:right"|2||{{#invoke:Math|precision_format|8765.567|2}} |- |style="text-align:right"| -2||{{#invoke:Math|precision_format|8765.567|-2}} |- |style="text-align:right"|6||{{#invoke:Math|precision_format|8765.567|6}} |- |style="text-align:right"| -6||{{#invoke:Math|precision_format|8765.567|-6}} |- |style="text-align:right"|2.5||{{#invoke:Math|precision_format|8765.567|2.5}} |- |style="text-align:right"| -2.5||{{#invoke:Math|precision_format|8765.567|-2.5}} |}
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)