Difference between revisions of "Template:Sigfigs"
From Kerbal Space Program Wiki
m (Improve rounding.) |
(+error handling;) |
||
Line 1: | Line 1: | ||
+ | <includeonly>{{#iferror:{{#expr:{{{1|}}}}}| <!-- | ||
{{#ifeq: {{{1}}}|N/A|N/A|{{#expr: <!-- | {{#ifeq: {{{1}}}|N/A|N/A|{{#expr: <!-- | ||
--> floor( 0.5 + <!-- | --> floor( 0.5 + <!-- | ||
--> {{{1|12345678901234567890}}} <!-- | --> {{{1|12345678901234567890}}} <!-- | ||
--> / 10^( <!-- | --> / 10^( <!-- | ||
− | --> floor(ln({{{1 | + | --> floor(ln({{{1}}}) / ln(10)) <!-- |
--> + 1 - {{{2|5}}} <!-- | --> + 1 - {{{2|5}}} <!-- | ||
--> ) <!-- | --> ) <!-- | ||
Line 9: | Line 10: | ||
--> * ( <!-- | --> * ( <!-- | ||
--> 10^( <!-- | --> 10^( <!-- | ||
− | --> floor(ln({{{1 | + | --> floor(ln({{{1}}}) / ln(10)) <!-- |
--> + 1 - {{{2|5}}} <!-- | --> + 1 - {{{2|5}}} <!-- | ||
--> ) <!-- | --> ) <!-- | ||
--> ) <!-- | --> ) <!-- | ||
− | + | }}}}|{{{1}}}}}</includeonly><noinclude> | |
{| class="wikitable" | {| class="wikitable" | ||
Line 22: | Line 23: | ||
|- | |- | ||
| <pre><nowiki>{{sigfigs|0.123456789012345678|5}}</nowiki></pre> || {{sigfigs|0.123456789012345678|5}} | | <pre><nowiki>{{sigfigs|0.123456789012345678|5}}</nowiki></pre> || {{sigfigs|0.123456789012345678|5}} | ||
+ | |- | ||
+ | | <pre><nowiki>{{sigfigs|Hello World|5}}</nowiki></pre> || {{sigfigs|Hello World|5}} | ||
|} | |} | ||
[[Category:Templates|sigfigs]] | [[Category:Templates|sigfigs]] | ||
</noinclude> | </noinclude> |
Revision as of 18:03, 15 February 2013
Usage | Produces |
---|---|
{{sigfigs|12345678901234567890|5}} |
1.2346×1019 |
{{sigfigs|0.123456789012345678|5}} |
0.12346 |
{{sigfigs|Hello World|5}} |
Expression error: Unrecognized word "hello". |