Difference between revisions 5293697 and 5293707 on simplewiki<noinclude><!-- - ================================================================== - Template:Convert/2 - Convert 2 units with any text between -================================================================== - (see NOTES at bottom) --></noinclude>{{#switch:{{{warn|no}}} | y|yes = {{#switch:{{{2|xby}}} | and|or|x|xx|by|-|+/-|,|to = <!--ok--> | #default = '''<span style="color:#DD6600">[[Template:Convert/2|Convert/2]] - Invalid<!-- --> parameter 2''' "{{{2|??}}}" - try: by, to, and,<!-- --> or, -, +/-, x, xx or comma. </span> }}<!--endswitch {2}--> }}<!--endswitch {warn}-- ------------------------------------------------- Check display -->{{#switch: {{{disp|b}}} <!--switch {disp} #1--> | 2|#|out| output only|number|output number only = | #default = <!-- ===================================================== Show inputs --------------------------------------- check {x0} --show-x0-->{{#if:{{{x0|}}}|{{ #switch: {{padleft:|1|{{{x0}}}z}} | ~|&|< = {{{x0}}} | #default = {{{x0}}} }} }}<!-- --------------------------------------- show amount 1 -->{{convert/numdisp|{{formatnum:{{{1|10}}}|R }}}}<!--show amount 1 --------------------------------------- check {x1} --show-x1-->{{#if:{{{x1|}}}|{{ #switch: {{padleft:|1|{{{x1}}}z}} | -|&|< = {{{x1}}} | #default = {{{x1}}} }} }}<!-- ------------------------------------------------ range-word 1 -->{{#switch:{{padleft:|1|{{{2|x}}}}} | -|,|/|) =<!--then no -/space--> | x| +/- = <!--then no break--> | (|[|{ =  <!--then lead-space--> | t={{#switch:{{{2}}}{{{abbr|o}}} | to(-)on | to(-)in = <!--none--> | #default= {{#switch:{{{adj|{{{sing|off}}}|}}} | off=  | split=-  | #default=-}} }}<!--endsw {2}{abbr}--> | #default= {{#switch:{{{adj|{{{sing|off}}}|}}} | off=  | split=-  | #default=-}}<!--if hyphen -->}}<!--endswitch {2}-->{{ #switch:{{{2|x}}}| x = ×<!--if {2}=x show small-x--> | - = –<!--if {2}=hyphen show dash--> | +/- = ±<!--if {2}=+/- show plus-minus--> | to(-)={{#switch:{{{abbr|def}}}| def|off|out=to |#default=–}} | #default={{{2|xx}}}<!--put range-word #1 -->}}<!--endswitch {2} word-->{{ #switch:{{padleft:|1|{{{2|x}}}}} | -|/ =<!--then no -/space--> | +/-|, = <!--then no break--> | (|[|{ = <!--no space after--> | t={{#switch:{{{2}}}{{{abbr|o}}} |to(-)on|to(-)in =<!--none--> | #default= {{#switch:{{{adj|{{{sing|off}}}|}}} | off=  | split=  | #default=-}} }}<!--endsw {2}{abbr}--> | #default= {{#switch:{{{adj|{{{sing|off}}}|}}} | off=  | split=  | #default=-}}<!--if hyphen -->}}<!--endswitch {2} after --------------------------------------- check {x2} --show-x2-->{{#if:{{{x2|}}}|{{ #switch: {{padleft:|1|{{{x2}}}z}} | -|&|< = {{{x2}}} | #default = {{{x2}}} }} }}<!-- --------------------------------------- show amount 2 -->{{convert/numdisp|{{formatnum:{{{3|20}}}|R}}}}<!--show amt2 in {3} --------------------------------------- check {x3} --show-x3-->{{#if:{{{x3|}}}|{{ #switch: {{padleft:|1|{{{x3}}}z}} | -|&|< = {{{x3}}} | #default = {{{x3}}} }} }}<!-- --------------------------------------- space/hyphen -->{{ #ifeq:{{{adj|off}}}|off| |-}}<!--if show hyphen-- -->{{convert|disp=unit |{{ #ifeq:{{{adj|off}}} |off | {{{3|2}}} |1 }}|{{{4|m}}}|abbr={{ #switch: {{{abbr|def}}}<!--condense 7 values to off/on/comma--> | def = {{#switch:{{{4|m}}} | F|C|K|R|°F|°C = on <!--force temperature as symbol--> | #default=def}} | off|out|none|comma|mos = off | on|in = on }}<!--endswitch {abbr}-- -->|lk={{{lk|off}}}|adj={{⏎ #ifeq: {{{adj|off}}} |split | on | {{{sing|{{{adj|off}}}}}}⏎ }}<!-- -->|sp={{{sp|}}} }}<!--show unit --------------------------------------- check {x4} --show-x4-->{{#if:{{{x4|}}}|{{ #switch: {{padleft:|1|{{{x4}}}z}} | -|&|< = {{{x4}}} | #default = {{{x4}}} }} }}<!-- ----------------------------------------------- Show separator -->{{#switch:{{{disp|b}}} | b =  ( | br|sqbr =  [ | or =  or  | s|/ =  /  | comma = ,  | semi|semicolon = ;  | x = <b>{{{6| [}}}</b> | #default = '''[[Template:Convert/2|Convert/2]] - Invalid<!-- --> separator''' "disp={{{disp|xx}}}" - try: disp=s, <!-- --> disp=or, disp=comma, disp=semi, disp=sqbr, disp=x or disp=b. }}<!--endswitch {2} --> }}<!--endswitch {disp} #1-- --------------------------------------- check {x5} --show-x5-->{{#if:{{{x5|}}}|{{ #switch: {{padleft:|1|{{{x5}}}z}} | -|&|< = {{{x5}}} | #default = {{{x5}}} }} }}<!-- ------------------------------------------------- Check show symbol -->{{#ifeq:{{{abbr|def}}}|~ |{{convert|1.0|{{{4|m}}}|disp=unit|abbr=on}},  }}<!-- ------------------------------------------------- Show results -->{{convert |{{{1|10}}}|{{{4|m}}}|<!--RESULT #1-->{{ #switch: {{{4|m}}} | lb = {{#ifeq:{{{5|ft}}}|km |kg |{{{5|}}} }} | mi = {{#ifeq:{{{5|ft}}}|kg |km |{{{5|}}} }} | sqft = {{#switch:{{{5|ft}}}|m|m3=m2 |km|km3=km2 |mi=sqmi |#default={{{5|m2}}} }} | #default = {{{5|}}} }}|<!--param.4-->{{#if:{{{p|}}} |{{#expr:{{{p}}} }} |{{#ifeq:{{{disp|b}}}|x |{{#if:{{{8|}}}|{{{8}}} }}<!--endif {8}--> |{{#if:{{{6|}}} |{{#expr: {{{6}}} }} |{{#expr: {{ #ifexpr: {{<!--numsense-->precision|{{{1|10}}}|}} > {{<!--numsense-->precision|{{{3|20}}}|}} |{{<!--numsense-->precision |{{{1|10}}}|}} |{{<!--numsense-->precision |{{{3|20}}}|}} }}<!--endifexpr numsense-->{{ #ifexpr: {{convert|{{#expr: abs( {{formatnum:{{{1|1}}}|R}} - {{formatnum:{{{3|3}}}|R}} ) }}|{{{4|m}}}|{{ #if:{{{5|}}}|{{{5}}}|{{#ifeq:{{{4|m}}}|m|ft|1}} }}|1|disp=number }} < 1 |+1 |+0 }}<!--endifexpr {convert| abs(diff)} < 1--> }}<!--endexpr--> }}<!--endif {6}--> }}<!--endif {disp}=x--> }}<!--endif {p} -->|sigfig={{#if:{{{sigfig|}}}|{{{sigfig|9}}} }}<!-- -->|disp=number<!-- SHOW RESULT 1 -- -->|abbr={{#ifeq:{{{abbr}}}|comma|comma|def}}<!-- --> }}<!-- --------------------------------------- check {x6} --show-x6-->{{#if:{{{x6|}}}|{{ #switch: {{padleft:|1|{{{x6}}}z}} | -|&|< = {{{x6}}} | #default = {{{x6}}} }} }}<!-- ------------------------------------------------- Show output range-word -->{{ #switch:{{padleft:|1|{{{2|x}}}}} | -|,|/|) =<!--then no -/space--> | x| +/- = <!--then no break--> | (|[|{ =  <!--then lead-space--> | t={{#switch:{{{2|to(-)}}}{{{abbr|on}}} | to(-)on | to(-)out = | #default= {{#switch:{{{adj|off}}}| off|split=  | #default=-}} }}<!--endsw {2}{abbr}--> | #default= {{#switch:{{{adj|off}}}| off|split=  | #default=-}}<!-- -->}}<!--endswitch {2}-->{{ #switch:{{{2|x}}}| x = ×<!--if {2}=x show small-x--> | - = –<!--if {2}=hyphen show dash--> | +/- = ±<!--if {2}=+/- show plus-minus--> | to(-)={{#switch:{{{abbr|on}}}| off|in=to |#default=–}} | #default={{{2|xx}}}<!--put range-word #1 -->}}<!--endswitch {2} word-->{{ #switch:{{padleft:|1|{{{2|x}}}}} | -|/ =<!--then no -/space--> | +/-|, = <!--then no break--> | (|[|{ = <!--no space after--> | t={{#switch:{{{2|to(-)}}}{{{abbr|on}}} | to(-)on | to(-)out = | #default= {{#switch:{{{adj|off}}}| off|split=  | #default=-}} }}<!--endsw {2}{abbr}--> | #default= {{#switch:{{{adj|off}}}| off|split=  | #default=-}}<!-- -->}}<!--endswitch {2} after --------------------------------------- check {x7} --show-x7-->{{#if:{{{x7|}}}|{{ #switch: {{padleft:|1|{{{x7}}}z}} | -|&|< = {{{x7}}} | #default = {{{x7}}} }} }}<!-- ----------------------------------------------------- SHOW RESULT #2 -->{{convert |{{{3|20}}}|<!--RESULT #2-->{{ #switch: {{{4|m}}} | C|°C={{#switch:{{{2}}}|+/-|±=C-change|#default={{{4}}} }} | F|°F={{#switch:{{{2}}}|+/-|±=F-change|#default={{{4}}} }} | #default = {{{4|m}}} }}|{{ #switch: {{{4|m}}} | lb = {{#ifeq:{{{5|ft}}}|km |kg |{{{5|}}} }} | mi = {{#ifeq:{{{5|ft}}}|kg |km |{{{5|}}} }} | sqft = {{#switch:{{{5|ft}}}|m|m3=m2 |km|km3=km2 |mi=sqmi |#default={{{5|m2}}} }} | C|°C={{#switch:{{{2}}}|+/-|±=F-change|#default={{{5|F}}} }} | F|°F={{#switch:{{{2}}}|+/-|±=C-change|#default={{{5|C}}} }} | #default = {{{5|ft}}} }}|<!--param.4-->{{#if:{{{p|}}} |{{#expr:{{{p}}} }} |{{#ifeq:{{{disp|b}}}|x |{{#if:{{{8|}}}|{{{8}}} }}<!--endif {8}--> |{{#if:{{{6|}}} |{{#expr: {{{6}}} }} |{{#expr: {{ #ifexpr: {{<!--numsense-->precision|{{{1|10}}}|}} > {{<!--numsense-->precision|{{{3|20}}}|}} | {{<!--numsense-->precision |{{{1|10}}}|}} | {{<!--numsense-->precision |{{{3|20}}}|}} }}<!--endifexpr numsense-->{{ #ifexpr: {{convert|{{#expr: abs( {{formatnum:{{{1|1}}}|R}} - {{formatnum:{{{3|3}}}|R}} ) }}|{{{4|m}}}|{{ #if:{{{5|}}}|{{{5}}}|{{#ifeq:{{{4|m}}}|m|ft|1}} }}|1|disp=number }} < 1 |+1 |+0 }}<!--endifexpr {convert| abs(diff)} < 1--> }}<!--endexpr--> }}<!--endif {6}--> }}<!--endif {disp}=x--> }}<!--endif {p} -->|sigfig={{#if:{{{sigfig|}}}|{{{sigfig|9}}} }}<!-- -->|disp={{#switch: {{{disp|b}}} <!--#2--> | #|number|output number only = number | #default = out<!--show result 3 & unit--> }}<!--endswitch {disp} #2-- -->|lk={{{lk|off}}}<!--use link-mode -->|abbr={{<!--use abbreviation-mode--> #switch:{{{abbr|on}}}<!--condense 7 values to off/on/comma--> | in = off | none|off = off | out|on|mos = on | comma = comma }}<!--endswitch {abbr}-- -->|adj={{#switch: {{{adj|{{{sing|off}}}}}}<!--use adjective-mode--> | off = off | #default=on }}<!-- -->|sp={{{sp|}}} }}<!--endconvert of 2nd amount --------------------------------------- check {x8} --show-x8-->{{#if:{{{x8|}}}|{{ #switch: {{padleft:|1|{{{x8}}}z}} | -|&|< = {{{x8}}} | #default = {{{x8}}} }} }}<!-- ------------------------------------------------- Show end text -->{{#switch:{{{disp|b}}} | b = ) | br|sqbr = ] | x = {{#if:{{{6|}}}|<b>{{{7|}}}</b>|]}}<!--put "]" if no {6} --> }}<!--when disp=b put parenthesis- --><noinclude><!-- -------------------------------------------------------------- -NOTES - - NOTE A1: This template converts 2 amounts, allowing any text - between the 2 amounts (and repeated between 2 results). - It allows any other options of Convert, such as disp=x. - Allows any text, unlike ranges which limit the separator. - A hyphen "-" will be displayed as an &ndash, and an "x" - will appear an an elevated small "x". - - NOTE D2: When using parameters 6-8, the output unit-code in - parameter 5 can be set to "0" for default output unit. - - NOTE P3: The rounding of the output amounts can be set by - passing p=2 to round both results to 2 decimal places. - Also, when disp=x, parameter 8 can be "|2" to round 2; - otherwise, parameter 6 as "|3" can round to 3 decimals. - -------------------------------------------------------------- -HISTORY: -06Jul11 Created, from Convert/3, for 2-amount unit ranges. -06Jul11 Allowed disp=s or disp=/ and put semicolon as "& #59". -06Jul11 Allowed display of input unit as abbr=none or lk=on/in. -06Jul11 Put NOTES comments to explain template operation. -06Jul11 Put HISTORY comments to log major changes (not typos). -06Jul11 Removed restrictions on separator unless "warn=yes". -06Jul11 For disp=2 (disp=out) shows just output amounts/unit. -06Jul11 For disp=# (disp=number) shows just output amounts. -06Jul11 For disp=x, shows parm.6 before, parm.7 after output. -06Jul11 New p=2 rounds both results to 2 decimal places. -06Jul11 Fixed to allow commas in the 2 amounts. -28Jul11 Fixed disp=x to show "]" only if no parameter {6}. -03Aug11 Replacing abbr=none with abbr=off per talk -10Aug11 Fixed abbr=off to use "off" rather than "none". -20Aug11 Added disp=sqbr (or =br) for square brackets "[ ]". -31Dec11 Fixed to allow "sigfig=n" digits. -30Apr13 Fixed disp=x to handle "(" or "[" or "{". -14Sep13 Fixed for {2}=to(-) at 24 settings of {abbr}+{adj}. -29Sep13 Allow new "adj=split" for splitting format "1- to 2-foot". -29Sep13 Uses {Convert/getunit} to show input unit/symbol. -02Oct13 Changed to force temperature default as symbol. -31Jan14 Added 9 custom parameters "x0=" to "x8=" as {convert/f}. -31Jan14 Auto-set precision as higher of both, +1 under 1.0 apart. -31Jan14 Set default precision +1 if converted range difference < 1. -31Jan14 Changed to show input unit symbol for abbr=~. -03Feb14 Fix when {4}=F|C as +/- to use F-change or C-change on {3}. -03Feb14 Auto-corrected for lb to km, mi to kg & sqft to m/km. -03Feb14 Unlinked {convert/old} but allows 1+3 in 'p=' or {6}. -04Jan16 Fixed adj=split to show singular "-unit" name. -04Jan16 Changed range "x" to repeat output unit symbol. -04Jan16 Restored {numsense} to fix precision 10-20 C. -04Jan16 Filter adj=split as adj=on to avoid Lua error.⏎ --> {{documentation}}{{#ifeq:{{SUBPAGENAME}}|sandbox|| <!-- This documentation page isused on multiple .pages. Some categories should be in the individual pages, not here. [[simple:Template:Convert/2]] -->}}</noinclude> All content in the above text box is licensed under the Creative Commons Attribution-ShareAlike license Version 4 and was originally sourced from https://simple.wikipedia.org/w/index.php?diff=prev&oldid=5293707.
![]() ![]() This site is not affiliated with or endorsed in any way by the Wikimedia Foundation or any of its affiliates. In fact, we fucking despise them.
|