Difference between pages "Template:Chem molar mass/format" and "Template:Chem molar mass/format/sandbox"

(Difference between pages)
Jump to navigation Jump to search
Page 1
Page 2
m (1 revision imported)
 
m (1 revision imported)
 
Line 1: Line 1:
{{#if:{{{fixed|}}}|{{#ifexpr:{{{value|}}}>0|[[Category:Chem-molar-mass both hardcoded and calculated]]}}}}{{#iferror:{{{value|}}}<!--
+
{{#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;">&#91;''[[Wikipedia:WikiProject Chemicals/Molar mass#Cannot calculate molar mass|<span title="Cannot calculate molar mass from chemical formula)">cannot calculate</span>]]''&#93;</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;">&#91;''[[Wikipedia:WikiProject Chemicals/Molar mass#Cannot calculate molar mass|<span title="Cannot calculate molar mass from chemical formula)">cannot calculate</span>]]''&#93;</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|{{{smart_round|2}}}}}<!-- min(2, smart) -->
+
  |yes={{min|2|{{#expr:floor(1-ln(({{{usquare|0.0001}}})^0.5)/ln(10))}}}}<!-- min(2, smart) -->
  |no={{{smart_round|2}}}<!-- smart -->
+
  |no={{#expr:floor(1-ln(({{{usquare|0.0001}}})^0.5)/ln(10))}}<!-- smart -->
  ||default|smart={{{smart_round|2}}}
+
  ||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}}}|{{{smart_round|2}}}}}<!-- when number; min(number, smart) -->}}
+
  |#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:
  
  
-xxx-> <small>(debug:smart_round={{{smart_round|(blank)}}})</small><!--
+
--> <small style="background:palegreen">(debug:usquare={{#expr: {{{usquare|(blank)}}} }};&nbsp;u={{#expr:{{{uncertainty|0}}}}};&nbsp;smart_round={{#if:{{{usquare}}}|{{#expr: (1-ln(({{{usquare|0.0001}}})^0.5)/ln(10)) }}|(blank)}});&nbsp;value={{{value|0}}};unrounded_uncertainty_digit={{#expr: {{{uncertainty|0}}} * (10 ^ floor(1-ln(({{{usquare|0.0001}}})^0.5)/ln(10))) }};&nbsp;one_uncertainty_digit={{#ifexpr: {{Precision|{{#expr: {{{uncertainty|0}}} * (10 ^ floor(1-ln(({{{usquare|0.0001}}})^0.5)/ln(10))) }} }} <= 0 | true | false}};&nbsp;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>