|
|
| (15 intermediate revisions by 4 users not shown) |
| Line 1: |
Line 1: |
| <includeonly><noinclude><!-- | | <includeonly>{{{{{♥|safesubst:}}}#invoke:val|main}}</includeonly><noinclude> |
| --></noinclude><span class="digits nowrap"><noinclude><!--
| |
| START ERROR CHECKING:
| |
| --></noinclude>{{#iferror:{{#expr:{{{1|0}}}}}<noinclude><!-- Is arg1 not a valid number?
| |
| arg1 isn't valid --></noinclude>|{{FormattingError|Error in {{tl|val}}: first argument is not a valid number.|nocategory={{{nocategory|}}}}}<noinclude><!--
| |
| arg1 is valid --></noinclude>|{{#iferror:{{#expr:{{{2|0}}}}}<noinclude><!-- Is arg2 not a valid number?
| |
| arg2 isn't valid --></noinclude>|{{FormattingError|Error in {{tl|val}}: second argument is not a valid number.|nocategory={{{nocategory|}}}}}<noinclude><!--
| |
| arg2 is valid --></noinclude>|{{#iferror:{{#expr:{{{3|0}}}}}<noinclude><!-- Is arg3 not a valid number?
| |
| arg3 isn't valid --></noinclude>|{{FormattingError|Error in {{tl|val}}: third argument is not a valid number.|nocategory={{{nocategory|}}}}}<noinclude><!--
| |
| arg3 is valid --></noinclude>|{{#ifexpr: {{{2|0}}} < 0<noinclude><!-- Is arg2 negative?
| |
| arg2 is negative --></noinclude>|{{FormattingError|Error in {{tl|val}}: second argument is negative.|nocategory={{{nocategory|}}}}}<noinclude><!--
| |
| arg2 is positive --></noinclude>|{{#iferror:{{#expr:{{{e|0}}}}}<noinclude><!-- Is arg "e" not a valid number?
| |
| "e" isn't valid --></noinclude>|{{FormattingError|Error in {{tl|val}}: exponent ('''e''') is not a valid number.|nocategory={{{nocategory|}}}}}<noinclude><!--
| |
| "e" is valid --></noinclude>|{{#ifeq:{{{u}}}{{{ul}}}|{{{u|}}}{{{ul|}}}<noinclude><!-- Is arg "u" and "ul" specified?
| |
| "u" & "ul" both specified --></noinclude>|{{FormattingError|Error in {{tl|val}}: unit ('''u''') and units with link ('''ul''') are both specified, only one is allowed.|nocategory={{{nocategory|}}}}}<noinclude><!--
| |
| "u" & "ul" not both specified --></noinclude>|{{#ifeq:{{{up}}}{{{upl}}}|{{{up|}}}{{{upl|}}}<noinclude><!-- Is arg "up" and "upl" specified?
| |
| "up" & "ulp" both specified --></noinclude>|{{FormattingError|Error in {{tl|val}}: unit per ('''up''') and units per with link ('''upl''') are both specified, only one is allowed.|nocategory={{{nocategory|}}}}}<noinclude><!--
| |
| "up" & "ulp" not both specified --></noinclude>|<noinclude><!--
| |
| END OPENING OF ERROR CHECKING, START OUTPUT
| |
| | |
| START HIDDEN SORT KEY
| |
| --></noinclude>{{#ifeq:{{{sortable}}}|off||{{val/sortkey|{{{sortval|{{{1|1}}}}}}|e={{{e|0}}}|u={{{us|{{{u|{{{ul|}}}}}}}}}|up={{{ups|{{{up|{{{upl|}}}}}}}}}|ls={{{long scale}}}}}}}<noinclude><!-- hidden sort key based on the SI base unit(s)
| |
| END HIDDEN SORT KEY
| |
| | |
| START PREFIX
| |
| --></noinclude>{{{p|}}}<noinclude><!-- If p (prefix) is defined, display it.
| |
| END PREFIX
| |
| | |
| START NUMERICAL OUTPUT
| |
| <noinclude><!-- numerical output --></noinclude>{{#if:{{{1|}}}<noinclude><!-- Are there any arguments?
| |
| There are arguments. --></noinclude>|{{#if:{{{2|}}}<noinclude><!-- Are there 2 or more arguments?
| |
| There are 2 or more arguments. --></noinclude>|{{#if:{{{3|}}}<noinclude><!-- Are there 3 arguments?
| |
| There are 3 arguments. --></noinclude>|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{1|}}}|u={{{u|{{{ul}}}}}}}}<noinclude><!-- Output arg1, formatted.
| |
| --></noinclude>{{{end|}}}{{val/angle|{{{u}}}|{{{ul}}}}}<noinclude><!-- Append something and/or add angle/percent symbol.
| |
| Uncertainty = +X/-Y --></noinclude>{{val/+-<noinclude><!-- Add + & - errors.
| |
| --></noinclude>|w={{{w|}}}|a={{{a|r}}}<noinclude><!-- Option fixed width, default right aligned
| |
| --></noinclude>|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{2}}}|nosign=on}}<noinclude><!-- Output +arg2, formatted.
| |
| --></noinclude>{{{+errend|}}}{{val/angle|{{{u|{{{ul}}}}}}}}<noinclude><!-- Append something and/or add angle/percent symbol.
| |
| --></noinclude>|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{3}}}|nosign=on}}<noinclude><!-- Output -arg3, formatted.
| |
| --></noinclude>{{{-errend|}}}{{val/angle|{{{u|{{{ul}}}}}}}}<noinclude><!-- Append something and/or add angle/percent symbol.
| |
| --></noinclude>}}<noinclude><!-- End are there 3 arguments (Uncertainty = +X/-Y)
| |
| --></noinclude>{{#if:{{{e|}}}<noinclude><!-- Is there an exponent?
| |
| There is an exponent. --></noinclude>|<span style="margin-left:0.25em;margin-right:0.15em">×</span>10<sup>{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{e}}}}}</sup><noinclude><!-- × 10^e
| |
| --></noinclude>}}<noinclude><!-- End is there an exponent
| |
| There are there not three arguments. --></noinclude>|{{#iferror:{{#expr:0{{{2}}}}}<noinclude><!-- Is second argument "(number)"?
| |
| Second argument is "(number)". --></noinclude>|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{1|}}}|u={{{u|{{{ul}}}}}}}}<noinclude><!-- Output arg1, formatted.
| |
| --></noinclude>{{{end|}}}{{{2}}}<noinclude><!-- Uncertainty (X)
| |
| --></noinclude>{{val/angle|{{{u}}}|{{{ul}}}}}<noinclude><!-- Add angle/percent symbol.
| |
| --></noinclude>{{#if:{{{e|}}}<noinclude><!-- Is there an exponent?
| |
| --></noinclude>|<span style="margin-left:0.25em;margin-right:0.15em">×</span>10<sup>{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{e}}}}}</sup><noinclude><!-- × 10^e
| |
| --></noinclude>}}<noinclude><!-- End is there an exponent
| |
| Second argument is not "(number)".--></noinclude>|{{#if:{{{e|}}}<noinclude><!-- Is there an exponent?
| |
| There is an exponent. --></noinclude>|({{val/delimitnum|fmt={{{fmt|gaps}}}|{{{1|}}}|u={{{u|{{{ul}}}}}}}}<noinclude><!-- Output arg1, formatted.
| |
| --></noinclude>{{{end|}}}{{val/angle|{{{u}}}|{{{ul}}}}}<noinclude><!-- Append something and/or add angle/percent symbol.
| |
| Uncertainty = ±X --></noinclude>{{val/±<noinclude><!-- Add ± symbol.
| |
| --></noinclude>|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{2}}}}}<noinclude><!-- Format number.
| |
| --></noinclude>{{{errend|}}}{{val/angle|{{{u|{{{ul}}}}}}}}<noinclude><!-- Append something and/or add angle/percent symbol.
| |
| --></noinclude>}})<noinclude><!-- End Uncertainty = ±X
| |
| --></noinclude><span style="margin-left:0.25em;margin-right:0.15em">×</span>10<sup>{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{e}}}}}</sup><noinclude><!-- × 10^e
| |
| There is no exponent. --></noinclude>|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{1|}}}|u={{{u|{{{ul}}}}}}}}<noinclude><!-- Output arg1, formatted.
| |
| --></noinclude>{{{end|}}}{{val/angle|{{{u}}}|{{{ul}}}}}<noinclude><!-- Append something and/or add angle/percent symbol.
| |
| Uncertainty = ±X --></noinclude>{{val/±<noinclude><!-- Add ± symbol.
| |
| --></noinclude>|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{2}}}}}<noinclude><!-- Format number.
| |
| --></noinclude>{{{errend|}}}{{val/angle|{{{u|{{{ul}}}}}}}}<noinclude><!-- Append something and/or add angle/percent symbol.
| |
| --></noinclude>}}<noinclude><!-- End Uncertainty = ±X
| |
| --></noinclude>}}<noinclude><!-- End is there and exponent.
| |
| --></noinclude>}}<noinclude><!-- End second argument is "(number)"?
| |
| --></noinclude>}}<noinclude><!-- End Are there 3 arguments?
| |
| 2 arguments? No --></noinclude>|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{1|}}}|u={{{u|{{{ul}}}}}}}}<noinclude><!-- Output arg1, formatted.
| |
| --></noinclude>{{{end|}}}{{val/angle|{{{u}}}|{{{ul}}}}}<noinclude><!-- Append something and/or add angle/percent symbol.
| |
| --></noinclude>{{#if:{{{e|}}}<noinclude><!-- Is there an exponent?
| |
| There is an exponent. --></noinclude>|<span style="margin-left:0.25em;margin-right:0.15em">×</span>10<sup>{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{e}}}}}</sup><noinclude><!-- × 10^e
| |
| --></noinclude>}}<noinclude><!-- End is there an exponent
| |
| --></noinclude>}}<noinclude><!-- End Are there 2 or more arguments?
| |
| There are no arguments. --></noinclude>|10<sup>{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{e|0}}}}}</sup><noinclude><!-- Output 10^e only.
| |
| --></noinclude>}}<noinclude><!-- End Are there any arguments?
| |
| END NUMERICAL OUTPUT
| |
| | |
| START UNITS
| |
| --></noinclude>{{#if:{{{up|}}}{{{upl|}}}
| |
| |
| |
| {{#if:{{{u|}}}
| |
| |
| |
| {{#ifexpr:{{#invoke:String|find|source={{{u}}}|target=[./*]|plain=false}}
| |
| |
| |
| {{#invoke:String|replace
| |
| |source =
| |
| {{#invoke:String|replace
| |
| <noinclude><!-- [[title|markup]]: & (or [) is 1st, [ is 7th (or 1st)--></noinclude>
| |
| |source = {{Val/units/sandbox|{{{u}}}}}
| |
| |pattern = %[%[.+{{!}} <noinclude><!--keeps , but compare others --></noinclude>
| |
| |replace = (
| |
| |plain = false
| |
| }}
| |
| |pattern = ]]
| |
| |replace = )
| |
| }}
| |
| | <noinclude><!-- Same thing, but without replace with parentheses --></noinclude>
| |
| {{#invoke:String|replace
| |
| |source =
| |
| {{#invoke:String|replace
| |
| |source = {{Val/units/sandbox|{{{u}}}}}
| |
| |pattern = %[%[.+{{!}}
| |
| |replace =
| |
| |plain = false
| |
| }}
| |
| |pattern = ]]
| |
| |replace =
| |
| }}
| |
| }}
| |
| }}<noinclude><!-- end up/upl AND u
| |
| --></noinclude>{{#if:{{{ul|}}} <noinclude><!-- With up/upl its possible to have neither u nor ul.--></noinclude>
| |
| |
| |
| {{#ifexpr:{{#invoke:String|find|source={{{ul}}}|target=[./*]|plain=false}}
| |
| | <noinclude><!-- Grouping parentheses --></noinclude>
| |
| {{#invoke:String|replace
| |
| |source =
| |
| {{#invoke:String|replace
| |
| |source = {{Val/units/sandbox|{{{ul}}}|ls={{{long scale}}}}}
| |
| |pattern = [ <noinclude><!-- keep spacing --></noinclude>
| |
| |replace = ([
| |
| |count = 1
| |
| }}
| |
| |pattern = %]%]
| |
| |replace = ]])
| |
| |plain = false <noinclude><!-- using %]%], not ]], prevents code mangle --></noinclude>
| |
| }}
| |
| | <noinclude><!-- normal call --></noinclude>
| |
| {{val/units/sandbox|{{{ul}}}|ls = {{{long scale}}}}}
| |
| }}
| |
| }}<noinclude><!-- End up/upl AND ul
| |
| --></noinclude>{{#if:{{{up|}}}
| |
| |
| |
| {{#ifexpr:{{#invoke:String|find|source={{{up}}}|target=[./*]|plain=false}}
| |
| |
| |
| {{#invoke:String|replace
| |
| |source =
| |
| {{#invoke:String|replace
| |
| |source = {{Val/units/sandbox|{{{up}}}}}
| |
| |pattern = .*%[%[.+{{!}} <noinclude><!-- remove spacing --></noinclude>
| |
| |replace = /(
| |
| |plain = false
| |
| }}
| |
| |pattern = ]]
| |
| |replace = )
| |
| }}
| |
| | <noinclude><!-- Same thing, but without replace with parentheses --></noinclude>
| |
| {{#invoke:String|replace
| |
| |source =
| |
| {{#invoke:String|replace
| |
| |source = {{Val/units/sandbox|{{{up}}}}}
| |
| |pattern = .*%[%[.+{{!}}
| |
| |replace = /
| |
| |plain = false
| |
| }}
| |
| |pattern = ]]
| |
| |replace =
| |
| }}
| |
| }}
| |
| | <noinclude><!-- upl --></noinclude>
| |
| {{#ifexpr:{{#invoke:String|find|source={{{upl}}}|target=[./*]|plain=false}}
| |
| |
| |
| {{#invoke:String|replace
| |
| |source =
| |
| {{#invoke:String|replace
| |
| |source = {{Val/units/sandbox|{{{upl}}}}}
| |
| |pattern = .-%[ <noinclude><!-- remove spacing --></noinclude>
| |
| |replace = /([
| |
| |plain = false
| |
| |count = 1
| |
| }}
| |
| |pattern = %]%]
| |
| |replace = ]])
| |
| |plain = false
| |
| }}
| |
| | <noinclude><!-- Same thing, but without replace with parentheses --></noinclude>
| |
| {{#invoke:String|replace
| |
| |source = {{val/units/sandbox|{{{upl}}}}}
| |
| |pattern = .-%[ <noinclude><!-- remove spacing: PCRE is .*?[ --></noinclude>
| |
| |replace = /[
| |
| |plain = false
| |
| |count = 1
| |
| }}
| |
| }}
| |
| }}
| |
| | <noinclude><!-- No up/upl --></noinclude>
| |
| {{#if:{{{u|}}}
| |
| |
| |
| {{#invoke:String|replace
| |
| |source =
| |
| {{#invoke:String|replace
| |
| |source = {{val/units/sandbox|{{{u}}}}}
| |
| |pattern = %[%[.+{{!}} <noinclude><!-- keep unit spacing --></noinclude>
| |
| |replace =
| |
| |plain = false
| |
| }}
| |
| |pattern = ]]
| |
| |replace =
| |
| }}
| |
| }}<noinclude><!--
| |
| --></noinclude>{{#if:{{{ul|}}}
| |
| |{{val/units/sandbox|{{{ul}}}|ls = {{{long scale}}}}}
| |
| }}
| |
| }}<noinclude><!-- end up/upl
| |
| END UNITS
| |
| | |
| START SUFFIX
| |
| --></noinclude>{{{s|}}}<noinclude><!-- If s (suffix) is defined, display it.
| |
| END PREFIX
| |
| | |
| START CLOSING OF ERROR CHECKING
| |
| --></noinclude>}}<noinclude><!-- End Is arg "up" and "upl" specified?
| |
| --></noinclude>}}<noinclude><!-- End Is arg "u" and "ul" specified?
| |
| --></noinclude>}}<noinclude><!-- End Is arg "e" not a valid number?
| |
| --></noinclude>}}<noinclude><!-- End Is arg2 negative?
| |
| --></noinclude>}}<noinclude><!-- End Is arg3 not a valid number?
| |
| --></noinclude>}}<noinclude><!-- End Is arg2 not a valid number?
| |
| --></noinclude>}}<noinclude><!-- End Is arg1 not a valid number?
| |
| END ERROR CHECKING
| |
| --></noinclude></span></includeonly><noinclude>
| |
| {{documentation}} | | {{documentation}} |
| </noinclude> | | </noinclude> |