Difference between pages "Template:Chem molar mass/format" and "Template:Chem molar mass/format/sandbox"
(Difference between pages)
Jump to navigation
Jump to search
Terranihil (talk | contribs) m (1 revision imported) |
m (1 revision imported) |
||
Line 1: | Line 1: | ||
− | + | {{#iferror:{{{value|}}}<!-- | |
iferror: true | iferror: true | ||
-->|{{#if:{{{fixed|}}}|<!-- error in fixed, return as is: -->{{{fixed|}}}|<!-- error is in calculation: --><sup class="noprint Inline-Template" style="white-space:nowrap;">[''[[Wikipedia:WikiProject Chemicals/Molar mass#Cannot calculate molar mass|<span title="Cannot calculate molar mass from chemical formula)">cannot calculate</span>]]'']</sup>}}{{main other|[[Category:Articles with erroneous molar mass calculations]]}}<!-- | -->|{{#if:{{{fixed|}}}|<!-- error in fixed, return as is: -->{{{fixed|}}}|<!-- error is in calculation: --><sup class="noprint Inline-Template" style="white-space:nowrap;">[''[[Wikipedia:WikiProject Chemicals/Molar mass#Cannot calculate molar mass|<span title="Cannot calculate molar mass from chemical formula)">cannot calculate</span>]]'']</sup>}}{{main other|[[Category:Articles with erroneous molar mass calculations]]}}<!-- | ||
Line 6: | Line 6: | ||
prefix: hidden sortkey ntsh | prefix: hidden sortkey ntsh | ||
buggy: this way, sorted is the non-rounded value... | buggy: this way, sorted is the non-rounded value... | ||
− | -->|{{#ifeq:{{{sortable|no}}}|yes|{{ntsh|1={{#if:{{{fixed|}}}|{{#invoke:String|match|s={{{fixed|}}} |pattern=^[%d%.%-%−]+ |plain=false |nomatch={{{fixed|0}}}}} |{{{value|0}}} }} |debug=no<!-- set to =yes to test/show the hidden key -->}} }}<!-- | + | -->|{{#ifeq: {{{mode|}}} | interval | [{{{lower_bound}}},{{{upper_bound}}}] | {{#ifeq:{{{sortable|no}}}|yes|{{ntsh|1={{#if:{{{fixed|}}}|{{#invoke:String|match|s={{{fixed|}}} |pattern=^[%d%.%-%−]+ |plain=false |nomatch={{{fixed|0}}}}} |{{{value|0}}} }} |debug=no<!-- set to =yes to test/show the hidden key -->}} }}<!-- |
round the value: | round the value: | ||
parameter round can be: yes, no, smart, number. | parameter round can be: yes, no, smart, number. | ||
Line 15: | Line 15: | ||
{{#ifexpr:{{{value|0}}}=0|<!-- no input, no value output -->|{{val|{{#invoke:math|precision_format |{{{value|0}}} | {{#ifexpr:{{{value|0}}}=0|<!-- no input, no value output -->|{{val|{{#invoke:math|precision_format |{{{value|0}}} | ||
|{{#switch:{{{round|smart}}} | |{{#switch:{{{round|smart}}} | ||
− | |yes={{min|2|{{{ | + | |yes={{min|2|{{#expr:floor(1-ln(({{{usquare|0.0001}}})^0.5)/ln(10))}}}}<!-- min(2, smart) --> |
− | |no={{{ | + | |no={{#expr:floor(1-ln(({{{usquare|0.0001}}})^0.5)/ln(10))}}<!-- smart --> |
− | ||default|smart={{{ | + | ||default|smart={{#expr:floor({{#ifexpr: {{Precision|{{#expr: {{{uncertainty|0}}} * (10 ^ floor(1-ln(({{{usquare|0.0001}}})^0.5)/ln(10))) }} }} <= 0 | 1 | 2}}-ln(({{{usquare|0.0001}}})^0.5)/ln(10))}} |
− | |#default={{min|{{{round|0}}}|{{{ | + | |#default={{min|{{{round|0}}}|{{#expr:floor(1-ln(({{{usquare|0.0001}}})^0.5)/ln(10))}} }}<!-- when number; min(number, smart) -->}} |
− | }} }} }} }}<!-- | + | }} | 2=({{#expr: ceil({{{uncertainty|0}}} * (10 ^ floor({{#ifexpr: {{Precision|{{#expr: {{{uncertainty|0}}} * (10 ^ floor(1-ln(({{{usquare|0.0001}}})^0.5)/ln(10))) }} }} <= 0 | 1 | 2}}-ln(({{{usquare|0.0001}}})^0.5)/ln(10)))) }}) }} }} }} }}<!-- |
iferror: close | iferror: close | ||
Line 29: | Line 29: | ||
− | - | + | --> <small style="background:palegreen">(debug:usquare={{#expr: {{{usquare|(blank)}}} }}; u={{#expr:{{{uncertainty|0}}}}}; smart_round={{#if:{{{usquare}}}|{{#expr: (1-ln(({{{usquare|0.0001}}})^0.5)/ln(10)) }}|(blank)}}); value={{{value|0}}};unrounded_uncertainty_digit={{#expr: {{{uncertainty|0}}} * (10 ^ floor(1-ln(({{{usquare|0.0001}}})^0.5)/ln(10))) }}; one_uncertainty_digit={{#ifexpr: {{Precision|{{#expr: {{{uncertainty|0}}} * (10 ^ floor(1-ln(({{{usquare|0.0001}}})^0.5)/ln(10))) }} }} <= 0 | true | false}}; uncertainty_decimal_places:{{Precision|{{#expr: {{{uncertainty|0}}} * (10 ^ floor(1-ln(({{{usquare|0.0001}}})^0.5)/ln(10))) }} }})</small><!-- |
--><noinclude>{{documentation|1=Template:Chem molar mass/doc}}</noinclude> | --><noinclude>{{documentation|1=Template:Chem molar mass/doc}}</noinclude> |