「テンプレート:Chem molar mass/format」の版間の差分

提供:脳科学辞典
ナビゲーションに移動 検索に移動
(1版)
 
(1版 をインポートしました)
 
(他の1人の利用者による、間の1版が非表示)
1行目: 1行目:
{{#iferror:{{{value|}}}|{{#if:{{{fixed|}}}|{{{fixed|}}}|<sup class="noprint Inline-Template" style="white-space:nowrap;">&#91;<i>[[Wikipedia:WikiProject Chemicals/Molar mass#Cannot calculate molar mass|<span title="Cannot calculate molar mass from chemical formula (atom counts not all numeric)">cannot calculate</span>]]</i>&#93;</sup>}}{{main other|[[Category:Articles with erroneous molar mass calculations]]}}|
{{#if:{{{fixed|}}}|{{#ifexpr:{{{value|}}}>0|[[Category:Chem-molar-mass both hardcoded and calculated]]}}}}{{#iferror:{{{value|}}}<!--
{{yesno |{{{sortable|no}}}<!--
iferror: true
-->|no=<!--
-->|{{#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]]}}<!--
-->{{#ifexpr:{{#expr:{{formatnum:{{{value|0}}}|R}}}}>0
  |{{#if:{{{fixed|}}} |{{{fixed|}}}<!--
      and categorize for maintenance because two values are entered:
    -->{{main other|{{#if:{{{catname|}}}<!--
      -->|[[{{#invoke:String|replace|source=Category:{{{catname|}}}<!--
      -->|pattern=^Category%:[Cc]ategory%:|replace=Category:|plain=false}}]]}}}}<!--


-->|{{#ifeq:{{{round|x}}}|no
iferror:false
|{{{value|0}}}
prefix: hidden sortkey ntsh
|{{#invoke:math|precision_format |{{{value|0}}} |{{{round|2}}} }}}}<!--
buggy: this way, sorted is the non-rounded value...
-->&nbsp;{{#if:{{{unit|}}} |{{{unit|}}} |g·mol<sup>−1</sup>}}
-->|{{#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:
  |{{{fixed|}}} }}<!--
parameter round can be: yes, no, smart, number.
rounding number cannot be greater than smart (=smart number of decimals), so use min(,).


-->|yes=<!--
smart number cannot be empty, but is covered with "|2" here
   -->{{ntsh|1={{#if:{{{fixed|}}} |{{#invoke:String|match|s={{{fixed|}}} |pattern=^[%d%.%-%−]+ |plain=false |nomatch={{{fixed|0}}} }} |{{{value|0}}}<!--
   -->{{#if:{{{fixed|}}}|{{{fixed|}}}|
-->|debug=no}} }}<!-- in a sandbox, set debug=yes to show the hidden sortkey number.
{{#ifexpr:{{{value|0}}}=0|<!-- no input, no value output -->|{{val|{{#invoke:math|precision_format |{{{value|0}}}  
-->{{#ifexpr:{{#expr:{{formatnum:{{{value|0}}}|R}}}}>0
|{{#switch:{{{round|smart}}}
  |{{#if:{{{fixed|}}}
|yes={{min|2|{{{smart_round|2}}}}}<!-- min(2, smart) -->
    |{{{fixed|}}}<!--
|no={{{smart_round|2}}}<!-- smart -->
-->|{{#ifeq:{{{round|x}}}|no
||default|smart={{{smart_round|2}}}
|{{{value|0}}}
|#default={{min|{{{round|0}}}|{{{smart_round|2}}}}}<!-- when number; min(number, smart) -->}}
|{{#invoke:math|precision_format |{{{value|0}}} |{{{round|2}}} }}
}} }} }} }}<!--
}} }}
  |{{{fixed|}}}<!--
-->}} }} }}<!--


iferror: close
-->}}<!--
suffix: if sort=no then add unit
-->{{#ifexpr:{{{value|0}}}=0||{{#ifeq:|{{{sortable|unk}}}|no|&nbsp;{{#if:{{{unit|}}} |{{{unit|}}}|g·mol<sup>−1</sup>}}}}}}<!--
  suffixes, will always show:
  suffixes, will always show:
-->{{{ref|}}}{{#if:{{{comment|}}}|&#x20;{{{comment|}}}}}<!--
-->{{{ref|}}}{{#if:{{{comment|}}}|&#x20;{{{comment|}}}}}<!--
--><noinclude>
{{documentation|1=Template:Chem molar mass/doc}}


</noinclude>
 
-xxx-> <small>(debug:smart_round={{{smart_round|(blank)}}})</small><!--
 
--><noinclude>{{documentation|1=Template:Chem molar mass/doc}}</noinclude>

2020年7月9日 (木) 16:11時点における最新版

[create] Documentation icon Template documentation