ಟೆಂಪ್ಲೇಟು:Gconvert

ವಿಕಿಪೀಡಿಯ ಇಂದ
Jump to navigation Jump to search


Template documentation[view] [edit] [history] [purge]

Usage[ಬದಲಾಯಿಸಿ]

The Template:Gconvert is a variation of Template:Convert, intended for general-purpose conversions, where the amount being converted is exactly specified, rather than being a possible estimate. To round the results to another level, append a parameter "-2" or "2" (etc.) when using Gconvert.

{{Gconvert|<num>|<unit>|<newunit>}}
{{Gconvert|<num>|<unit>|<newunit>|2}} - show 2 decimals
{{Gconvert|<num>|<unit>|<newunit>|-2}} - round hundreds
{{Gconvert|<n>|<unit1>|<n2>|<unit2>|<newunit>}} -for 2 units

The parameters are identical to Template:Convert. The options include: abbr=off, abbr=on, sp=us, disp=/, disp=or, disp=s, disp=output number only, adj=on (explained below).

Parameters[ಬದಲಾಯಿಸಿ]

The following are the parameters handled by Template:Gconvert:

  • Parameter 1 is the amount to convert, can contain commas or a formula.
  • abbr=off - turns off abbreviation, shows "meters" or "feet" (default: abbr=on).
  • sp=us - triggers U.S. spelling, shows "meters" else "metres" (default: sp=en).
  • disp=/   - displays slash between numbers (default: disp=b).
  • disp=s   - displays slash between numbers (same as disp=/).
  • disp=or - displays "or" between numbers (default: parentheses).
  • disp=table - displays a hidden sort-tag for use in sortable tables.
  • disp=output number only - displays only the resulting number.
  • adj=on - turns on adjective-mode, shows "-m" (default: adj=off).

Those parameters are the same as in template {{Convert}}.

Examples[ಬದಲಾಯಿಸಿ]

{{Gconvert|0.01|m}}   gives:  ೦.೦೧ metres (.)
{{Gconvert|1.03|m}}   gives:  ೧.೦೩ metres (೩)
{{Gconvert|3.6|m}}     gives:  ೩.೬ metres ( ft)
{{Gconvert|5|kg}}         gives:  ೫ kilograms ( lb)
{{Gconvert|8|km|abbr=on}}     gives:  ೮ km ( mi)
{{Gconvert|33|kg}}         gives:  ೩೩ kilograms ( lb)
{{Gconvert|83|kg}}         gives:  ೮೩ kilograms ( lb)
{{Gconvert|180|km}}       gives:  ೧೮೦ kilometres ( mi)
Heights
{{Gconvert|32|m|ft}}        gives:  ೩೨ metres ( ft)
{{Gconvert|200|m|ft}}      gives:  ೨೦೦ metres ( ft)
{{Gconvert|200.3|m|ft}}   gives:  ೨೦೦.೩ metres ( ft)
{{Gconvert|1,247|m}}     gives:  ೧,೨೪೭ metres ( ft)

{{Gconvert|6|ft|2|in|cm}}     gives:  ೬ feet 2 inches ( cm)
{{Gconvert|6|ft|2|in|m}}       gives:  ೬ feet 2 inches (. m)
Altitudes
{{Gconvert|8,848|m}}            gives:  ೮,೮೪೮ metres ( ft) - Mount Everest
{{Gconvert|8,848|±|0.4|m}}    gives:  .
Formulas and fractions
{{Gconvert| 16*90 |kg|lb}}       gives:  ೧೬ kilograms ( lb) - math formula
{{Gconvert|29*1,000 +29|ft|m}}     gives:  ೨೯ feet ( m)

{{Gconvert| 16*90.1 |kg|lb}}     gives:  ೧೬.೧ kilograms ( lb)
{{Gconvert| 16*90.1 |kg|lb|1}}   gives:  ೧೬.೧ kilograms (. lb) - rounded 1 decimal
{{Gconvert|1+1/8|mi|km}}     gives:   18 miles (. km)
{{Gconvert|1/3|yd|m}}           gives:  13 yard (�.{{#iferror:{{#ifexpr:{{formatnum:�.|R}}<1000| | }}| }}{{#iferror:{{#ifexpr:abs( {{formatnum:�.|R}} ) < 1.0001|m|m}}|m}}) - third of a yard
{{Gconvert|1.01|ft|m}}           gives:  ೧.೦೧ feet (. m)
{{Gconvert|1.65*1.3333|ft|m|2}}     gives:  ೧.೬೫ feet (. m)
{{Gconvert|1,765*1,100|km|mi}}     gives:  ೧,೭೬೫ kilometres ( mi)
{{Gconvert|10*pi|km|km}}     gives:  10*pi km (31.415926535898 km) ← with pi
{{Gconvert|10*pi*10|km|mi}}     gives:  ೧೦ kilometres (. mi) ← circle area
{{Gconvert|ln 10|km|km}}     gives:  ln 10 km (2.302585092994 km) ← natural log
Both same units
{{Gconvert| 8*27|kg|kg}}        gives:  8*27 kg (216 kg) - both same units
{{Gconvert| 4*5.5|kg|kg|disp=equals}}   gives:  4*5.5 kg equals 22 kg
{{Gconvert| 35*10|m|m|disp=output number only}}   gives:  350
{{Gconvert| 45*20|kg|kg|disp=output only}}   gives:  900 kg
Various display options
{{Gconvert|89|cm|in|disp=/}}             gives:  ೮೯ centimetres / inches ← use slash
{{Gconvert|100|lb|kg|disp=b}}           gives:  ೧೦೦ pounds ( kg) ← use parentheses
{{Gconvert|55|mph|km/h|disp=or}}     gives:  ೫೫ miles per hour or kilometres per hour
{{Gconvert| 627 |kg|disp=output number only}}              gives: 
{{Gconvert| 350|L|USgal|disp=output only|abbr=on}}      gives:   US gal
{{Gconvert| 3.785|L|USgal|disp=output only}}                     gives:  ೧ US gal
{{Gconvert| 60 |mph|disp=output only|abbr=on|lk=on}}    gives:   km/h
{{Gconvert| 0.622 |mph|disp=output only|abbr=off|lk=on}}   gives:  . km/h

Settings for precision[ಬದಲಾಯಿಸಿ]

For calculations made by Template:Gconvert, the numbers are assumed to be precise to the last digit. The converted result will be displayed to an equivalent precision. For example, the number "200" is treated as 199+1, so for distance: 200 metres (656 ft).

Features for simplicity[ಬದಲಾಯಿಸಿ]

Several features provide extra simplicity, beyond the operation of Template:Convert:

  • Gconvert allows the input amount to be a formula: 75*84 + 13.5
  • The input number (or formula) can contain commas: 1,500,175
  • When both units are the same, it just calculates: {{Gconvert|6*137|ft|ft}} → 6*137 ft (822 ft)
  • Gconvert validates parameters, such as: "Invalid parameter: abbr=nope, try abbr=on or abbr=off."
  • Numbers are treated as precise to the last digit (so "200" is treated as 199+1, rather than being roughly 2 hundred rounded from 151-249). Gconvert considers 200 m as 656 ft, whereas Convert rounds as 660 ft.
  • A space can precede the amount (spaces in Convert can cause: "Expression error...").

When changing from Gconvert to Template:Convert, then any commas or formulas, in the input amount, must be changed to simple numbers or fractions: 1/3 or 3/4. To use the same level of precision, add decimal point "." after numbers (such as "200." to indicate 199+1), when changing from Gconvert to Convert.

Limitations[ಬದಲಾಯಿಸಿ]

The following are potential issues:

  • A tiny decimal less than 0.03 is rounded to 3 decimal digits.
  • A formula can only contain division "/" for same-unit conversion, else treated as a fraction.
  • A formula with "pi" (or "ln" natural logarithm) should start with a number, not pi.
  • When changing from Gconvert to Convert, a leading blank before a number can cause the following message: "Expression error: Unexpected...". Write a number with no preceding space, as "627" (rather than "  627") if going back to Convert.

See also[ಬದಲಾಯಿಸಿ]