Template:Val: Difference between revisions

From Zoophilia Wiki
Jump to navigationJump to search
meta>Jimp
(simpler way to throw out the sign)
meta>Jimp
(add exponents for errors, move prefix outside brackets, merge exponent part with main part to a numerical part and move errors off to subtemplates. See Template talk:Val#13 May 2015 restructure.)
Line 19: Line 19:
END OPENING OF ERROR CHECKING, START OUTPUT
END OPENING OF ERROR CHECKING, START OUTPUT


START OPENING BRACKET
START HIDDEN SORT KEY
-->{{#if:{{{1|}}}|<!-- Are there any arguments?
-->{{#ifeq:{{{sortable}}}|off||{{val/sortkey|{{{sortval|{{{1|1}}}}}}|e={{{e|0}}}|u={{{us|{{{u|{{{ul|}}}}}}}}}|up={{{ups|{{{up|{{{upl|}}}}}}}}}|ls={{{long scale}}}}}}}<!--       hidden sort key based on the SI base unit(s)
-->{{#if:{{{2|}}}|<!-- Are there 2 arguments?
END HIDDEN SORT KEY
  -->{{#if:{{{3|}}}|<!-- Are there 3 arguments?
  -->|<!-- There are 2, but not 3 arguments
    -->{{#if:{{#ifexpr:0{{{2}}}}}|<!-- Second argument is "(number)"? YES, do not check for bracket
                              -->|<!-- Second argument is "(number)"? NO, check for bracket
                              -->{{#if:{{{e|}}}|(<!-- Is there an exponent? YES, open bracket
                              -->}}<!-- End is there an exponent?
    -->}}<!-- End is second argument "(number)"?
  -->}}<!-- end Are there 3 arguments?
-->}}<!-- end Are there 2 arguments?
-->}}<!-- end Are there any arguments?
END OPENING BRACKET


START MAIN OUTPUT
START PREFIX
                -->{{#ifeq:{{{sortable}}}|off||{{val/sortkey|{{{sortval|{{{1|1}}}}}}|e={{{e|0}}}|u={{{us|{{{u|{{{ul|}}}}}}}}}|up={{{ups|{{{up|{{{upl|}}}}}}}}}|ls={{{long scale}}}}}}}<!--        hidden sort key based on the SI base unit(s)
-->{{{p|}}}<!-- If p (prefix) is defined, display it.
                -->{{{p|}}}<!-- If p (prefix) is defined, display it.
END PREFIX
                -->{{#if: {{{1|}}}|<!-- Are there any arguments?
                -->{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{1|}}}|u={{{u|{{{ul}}}}}}}}<!--
                            Output arg1, formatted.
                -->{{{end|}}}<!--
                  -->{{#if: {{{2|}}}|<!-- Are there 2 or more arguments?
                  -->{{#if: {{{3|}}}|<!-- Are there 3 arguments?
                          There are three arguments.
                    -->{{val/angle|{{{u}}}|{{{ul}}}}}<!-- Uncertainty = +X/-Y
                    --><span style="margin-left:0.3em;">{{su|<!--
                        -->w={{{w|}}}|a={{{a|r}}}|<!--
                              Option fixed width, default right aligned


                        -->p=+{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{2}}}|nosign=on}}<!--
START NUMERICAL OUTPUT
                              Output +arg2, formatted.
<!--  numerical output            -->{{#if:{{{1|}}}<!--                                                    Are there any arguments?
                        -->{{{+errend|}}}{{val/angle|{{{u|{{{ul}}}}}}}}|<!--
There are arguments.                -->|{{#if:{{{2|}}}<!--                                                     Are there 2 or more arguments?
                              Append something and/or add angle/percent symbol.
  There are 2 or more arguments.       -->|{{#if:{{{3|}}}<!--                                                    Are there 3 arguments?
      There are 3 arguments.              -->|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{1|}}}|u={{{u|{{{ul}}}}}}}}<!-- Output arg1, formatted.
                        -->b=−{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{3}}}|nosign=on}}<!--
                                            -->{{{end|}}}{{val/angle|{{{u}}}|{{{ul}}}}}<!--                           Append something and/or add angle/percent symbol.
                              Output -arg3, formatted.
              Uncertainty = +X/-Y          -->{{val/+-<!--                                                          Add + & - errors.
                        -->{{{-errend|}}}{{val/angle|{{{u|{{{ul}}}}}}}}<!--
                                              -->|w={{{w|}}}|a={{{a|r}}}<!--                                           Option fixed width, default right aligned
                              Append something and/or add angle/percent symbol.
                                              -->|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{2}}}|nosign=on}}<!--           Output +arg2, formatted.
 
                                                -->{{{+errend|}}}{{val/angle|{{{u|{{{ul}}}}}}}}<!--                     Append something and/or add angle/percent symbol.
                    -->}}</span><!-- End Uncertainty = +X/-Y
                                                -->{{#if:{{{erre|{{{+erre|}}}}}}<!--                                 Is there a +error exponent?
 
                  There is a +error exponent.     -->|<span style="margin-left:0.25em;margin-right:0.15em">×</span>10<sup>{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{erre|{{{+erre}}}}}}}}</sup><!-- × 10^+erre
                    -->|<!--
                                                -->}}<!--                                                             End is there a +error exponent
 
                                              -->|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{3}}}|nosign=on}}<!--       Output -arg3, formatted.
                          There are there not three arguments.
                                                -->{{{-errend|}}}{{val/angle|{{{u|{{{ul}}}}}}}}<!--                   Append something and/or add angle/percent symbol.
                      -->{{#if:{{#ifexpr: 0{{{2}}}}}<!-- Is second argument "(number)"?   
                                                -->{{#if:{{{erre|{{{-erre|}}}}}}<!--                                 Is there a -error exponent?
                        -->|<!--  
                  There is a -error exponent.     -->|<span style="margin-left:0.25em;margin-right:0.15em">×</span>10<sup>{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{erre|{{{-erre}}}}}}}}</sup><!-- × 10^-erre
                            Second argument is "(number)".
                                                -->}}<!--                                                             End is there a +error exponent
                            Significance = (X)
                                            -->}}<!--                                                             End are there 3 arguments (Uncertainty = +X/-Y)
                        -->{{{2}}}{{val/angle|{{{u}}}|{{{ul}}}}}<!--  
                                            -->{{#if:{{{e|}}}<!--                                                 Is there an exponent?
                        -->|<!--
              There is an exponent.          -->|<span style="margin-left:0.25em;margin-right:0.15em">×</span>10<sup>{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{e}}}}}</sup><!-- × 10^e
                            Second argument is not "(number)".
                                            -->}}<!--                                                             End is there an exponent
                            Uncertainty = ±X.
      There are there not three arguments. -->|{{#iferror:{{#expr:0{{{2}}}}}<!--                                   Is second argument "(number)"?  
                            Add angle/percent symbol.
            Second argument is "(number)".    -->|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{1|}}}|u={{{u|{{{ul}}}}}}}}<!-- Output arg1, formatted.
                        -->{{val/angle|{{{u}}}|{{{ul}}}}}<!--
                                              -->{{{end|}}}{{{2}}}<!--                                               Uncertainty (X)
                            Add ± symbol.
                                              -->{{val/angle|{{{u}}}|{{{ul}}}}}<!--                                 Add angle/percent symbol.
                        --><span style="margin-left:0.3em;margin-right:0.15em">±</span><!--
                                              -->{{#if:{{{e|}}}<!--                                               Is there an exponent?
                            Format number.
                                                -->|<span style="margin-left:0.25em;margin-right:0.15em">×</span>10<sup>{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{e}}}}}</sup><!-- × 10^e
                        -->{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{2}}}}}<!--
                                              -->}}<!--                                                          End is there an exponent
                            Append something and/or add angle/percent symbol.
            Second argument is not "(number)".-->|{{#if:{{{e|}}}<!--                                                 Is there an exponent?
                        -->{{{errend|}}}{{val/angle|{{{u|{{{ul}}}}}}}}<!--
              There is an exponent.              -->|{{#if:{{{erre|}}}<!--                                               Is there an error exponent?
                There is an error exponent.       -->|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{1|}}}|u={{{u|{{{ul}}}}}}}}<!--  Output arg1, formatted.
                      -->}}<!-- End second argument is "(number)"?
                                                    -->{{{end|}}}{{val/angle|{{{u}}}|{{{ul}}}}}<!--                     Append something and/or add angle/percent symbol.
                  -->}}<!-- End Are there 3 arguments?
                                                    --><span style="margin-left:0.25em;margin-right:0.15em">×</span>10<sup>{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{e}}}}}</sup><!-- × 10^e
  2 arguments? No -->|{{val/angle|{{{u}}}|{{{ul}}}}}<!--
                    Uncertainty = ±X                -->{{val/±<!--                                                      Add ± symbol.
                  -->}}<!-- End Are there 2 or more arguments?
                                                        -->|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{2}}}}}<!--              Format number.
                -->}}<!-- End Are there any arguments?
                                                        -->{{{errend|}}}{{val/angle|{{{u|{{{ul}}}}}}}}<!--                Append something and/or add angle/percent symbol.
END MAIN OUTPUT
                                                    -->}}<!--                                                          End Uncertainty = ±X
 
                                                    --><span style="margin-left:0.25em;margin-right:0.15em">×</span>10<sup>{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{erre}}}}}</sup><!-- × 10^erre
START CLOSING BRACKET
                There is no error exponent.        -->|({{val/delimitnum|fmt={{{fmt|gaps}}}|{{{1|}}}|u={{{u|{{{ul}}}}}}}}<!--  Output arg1, formatted.
-->{{#if:{{{1|}}}|<!-- Are there any arguments?
                                                    -->{{{end|}}}{{val/angle|{{{u}}}|{{{ul}}}}}<!--                    Append something and/or add angle/percent symbol.
-->{{#if:{{{2|}}}|<!-- Are there 2 arguments?
                    Uncertainty = ±X                -->{{val/±<!--                                                      Add ± symbol.
  -->{{#if:{{{3|}}}|<!-- Are there 3 arguments?
                                                        -->|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{2}}}}}<!--              Format number.
  -->|<!-- There are 2, but not 3 arguments
                                                        -->{{{errend|}}}{{val/angle|{{{u|{{{ul}}}}}}}}<!--                Append something and/or add angle/percent symbol.
    -->{{#if:{{#ifexpr:0{{{2}}}}}|<!-- Second argument is "(number)"? YES, do not check for bracket
                                                    -->}})<!--                                                          End Uncertainty = ±X
                              -->|<!-- Second argument is "(number)"? NO, check for bracket
                                                    --><span style="margin-left:0.25em;margin-right:0.15em">×</span>10<sup>{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{e}}}}}</sup><!-- × 10^e
                              -->{{#if:{{{e|}}}|)<!-- Is there an exponent? YES, close bracket
                                                  -->}}<!--                                                          End is there an error exponent
                              -->}}<!-- End is there an exponent?
              There is no exponent.              -->|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{1|}}}|u={{{u|{{{ul}}}}}}}}<!--  Output arg1, formatted.
    -->}}<!-- End is second argument "(number)"?
                                                  -->{{{end|}}}{{val/angle|{{{u}}}|{{{ul}}}}}<!--                        Append something and/or add angle/percent symbol.
  -->}}<!-- end Are there 3 arguments?
                  Uncertainty = ±X                -->{{val/±<!--                                                        Add ± symbol.
-->}}<!-- end Are there 2 arguments?
                                                    -->|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{2}}}}}<!--                  Format number.
-->}}<!-- end Are there any arguments?
                                                      -->{{{errend|}}}{{val/angle|{{{u|{{{ul}}}}}}}}<!--                    Append something and/or add angle/percent symbol.
END OPENING BRACKET
                                                  -->}}<!--                                                              End Uncertainty = ±X
 
                                                -->{{#if:{{{erre|}}}<!--                                                Is there an error exponent?
START EXPONENT
                There is an error exponent.        -->|<span style="margin-left:0.25em;margin-right:0.15em">×</span>10<sup>{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{erre}}}}}</sup><!-- × 10^erre
-->{{#if:{{{e|}}}<!-- Is there an exponent?
                                                  -->}}<!--                                                              End is there an error exponent
          YES -->|{{#if:{{{1|}}}<!-- Are there any argument?
                                              -->}}<!--                                                              End is there and exponent.
                        YES -->|<span style="margin-left:0.25em;margin-right:0.15em">×</span>10<sup>{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{e}}}}}</sup><!--
                                            -->}}<!--                                                              End second argument is "(number)"?
                        NO -->|10<sup>{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{e}}}}}</sup><!--
                                        -->}}<!--                                                              End Are there 3 arguments?
              -->}}<!-- End are there any argument?<!--
  2 arguments? No                      -->|{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{1|}}}|u={{{u|{{{ul}}}}}}}}<!--  Output arg1, formatted.
-->}}<!-- End is there an exponent?
                                        -->{{{end|}}}{{val/angle|{{{u}}}|{{{ul}}}}}<!--                        Append something and/or add angle/percent symbol.
END EXPONENT
                                        -->{{#if:{{{e|}}}<!--                                                  Is there an exponent?
      There is an exponent.                -->|<span style="margin-left:0.25em;margin-right:0.15em">×</span>10<sup>{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{e}}}}}</sup><!-- × 10^e
                                        -->}}<!--                                                              End is there an exponent
                                      -->}}<!--                                                              End Are there 2 or more arguments?
There are no arguments.              -->|10<sup>{{val/delimitnum|fmt={{{fmt|gaps}}}|{{{e|0}}}}}</sup><!-- Output 10^e only.
                                  -->}}<!--                                                              End Are there any arguments?
END NUMERICAL OUTPUT


START UNITS
START UNITS
Line 133: Line 117:
   -->{{#if:{{{ul|}}}|{{val/unitswithlink|{{{ul}}}|nbsp|ls={{{long scale}}}}}}}<!--
   -->{{#if:{{{ul|}}}|{{val/unitswithlink|{{{ul}}}|nbsp|ls={{{long scale}}}}}}}<!--
-->}}<!--  
-->}}<!--  
END UNITS
START SUFFIX
-->{{{s|}}}<!-- If s (suffix) is defined, display it.
-->{{{s|}}}<!-- If s (suffix) is defined, display it.
 
END PREFIX
 
END UNITS


START CLOSING OF ERROR CHECKING
START CLOSING OF ERROR CHECKING
-->}}<!-- End Is arg "up" and "upl" specified?
                  -->}}<!-- End Is arg "up" and "upl" specified?
-->}}<!-- End Is arg "u" and "ul" specified?
              -->}}<!-- End Is arg "u" and "ul" specified?
-->}}<!-- End Is arg "e" not a valid number?
            -->}}<!-- End Is arg "e" not a valid number?
-->}}<!-- End Is arg2 negative?
        -->}}<!-- End Is arg2 negative?
-->}}<!-- End Is arg3 not a valid number?
      -->}}<!-- End Is arg3 not a valid number?
-->}}<!-- End Is arg2 not a valid number?
  -->}}<!-- End Is arg2 not a valid number?
-->}}<!-- End Is arg1 not a valid number?
-->}}<!-- End Is arg1 not a valid number?
END ERROR CHECKING
END ERROR CHECKING

Revision as of 21:58, 12 May 2015