Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Template:Convert/doc
(section)
Template
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Rounding: ''100 ft'' is ''30 m'' or ''30.5 m'' or ''30.48 m''?<span class="anchor" id="Rounding"></span>== {{hatnote|See {{section link|Help:Convert#Rounding}} for a more mathematical description of the rounding options}} By definition, 100 ft equals {{convert|100|ft|m|sigfig=4|disp=out}}. In practical use, it is common to round the calculated metric number. With that, there are several possibilities. ===Default rounding=== By {{tlf|Convert}} default, the conversion result will be rounded either to precision comparable to that of the input value (the number of digits after the decimal pointβor the negative of the number of non-significant zeroes before the pointβis increased by one if the conversion is a multiplication by a number between 0.02 and 0.2, remains the same if the factor is between 0.2 and 2, is decreased by 1 if it is between 2 and 20, and so on) or to two significant digits, whichever is more precise. An exception to this is ''rounding temperatures'' (see [[#Rounding temperatures|below]]). {| class="wikitable" |- ! colspan="3" | Examples of rounding |- |'''Input'''||'''Displays as'''||'''Note''' |- |<code><nowiki>{{convert|123|ft|m|-1}}</nowiki></code> || {{convert|123|ft|m|-1}} || |- |<code><nowiki>{{convert|123|ft|m}}</nowiki></code> || {{convert|123|ft|m}} || same output as with 0 (below) |- |<code><nowiki>{{convert|123|ft|m|0}}</nowiki></code> || {{convert|123|ft|m|0}} || |- |<code><nowiki>{{convert|123|ft|m|1}}</nowiki></code> || {{convert|123|ft|m|1}} || |- |<code><nowiki>{{convert|123|ft|m|2}}</nowiki></code> || {{convert|123|ft|m|2}} ||123 [[Foot (unit)#Definition|feet]] is exactly 37.4904 m which is rounded to 37 m if this parameter is not specified at all |- |<code><nowiki>{{convert|500|ft|m|-1}}</nowiki></code> || {{convert|500|ft|m|-1}} || |- |<code><nowiki>{{convert|500|ft|m}}</nowiki></code> || {{convert|500|ft|m}} || same output as with <code>-1</code> (above), because the conversion factor is between 0.2 and 2 (hence, it should produce same double-zero precision (β2) as in the input value), but the conversion must produce two significant digits at a minimum (hence, a higher single-zero precision (β1) is used) |- |<code><nowiki>{{convert|500|ft|m|0}}</nowiki></code> || {{convert|500|ft|m|0}} || |- |<code><nowiki>{{convert|500|ft|m|1}}</nowiki></code> || {{convert|500|ft|m|1}} || |- |<code><nowiki>{{convert|500|ft|m|2}}</nowiki></code> || {{convert|500|ft|m|2}} || exact value is 152.4 m |- |<code><nowiki>{{convert|500|ft|cm|-3}}</nowiki></code> || {{convert|500|ft|cm|-3}} || |- |<code><nowiki>{{convert|500|ft|cm}}</nowiki></code> || {{convert|500|ft|cm}} || same output as with <code>-3</code> (above), because the conversion factor is between 20 and 200 (hence, it should decrease input value's double-zero precision (β2) by 2), but the conversion must produce two significant digits at a minimum (hence, a higher triple-zero precision (β3) is used) |- |<code><nowiki>{{convert|500|ft|cm|0}}</nowiki></code> || {{convert|500|ft|cm|0}} || |}<!--NOTE: rows require "nowiki", using {{ disappears. --> ''Convert'' supports four types of rounding: ===Round to a given precision: ''use a precision number''=== Specify the desired precision with an integer as the ''fourth unnamed parameter'' (or third unnamed parameter if the "convert to" parameter is omitted; or fifth unnamed parameter if a range is specified; or fourth unnamed parameter again if a range is specified and the "convert to" parameter is omitted; needs to be replaced with a "precision" named parameter). The conversion is rounded off to the nearest multiple of {{frac|10}} to the power of this integer. For instance, if the result is 8621 and the rounding parameter is "β2", 8600 will be displayed. If the result is "123.456" and the parameter is "0", 123 will be displayed. Essentially a positive or zero rounding parameter specifies the number of decimal places; a negative value specifies the number of trailing zeroes. ===Round to a given number of significant figures: ''{{para|sigfig|}}''<span class="anchor" id="Round to a given number of significant figures"></span>=== To specify the output number to be with ''n'' significant figures use {{para|sigfig|<number>}}: * <code><nowiki>{{convert|1200|ft|m|sigfig=4}}</nowiki></code> β {{convert|1200|ft|m|sigfig=4}} * <code><nowiki>{{convert|1200|ft|m|sigfig=3}}</nowiki></code> β {{convert|1200|ft|m|sigfig=3}} * <code><nowiki>{{convert|1200|ft|m|sigfig=2}}</nowiki></code> β {{convert|1200|ft|m|sigfig=2}} * <code><nowiki>{{convert|1200|ft|m|sigfig=1}}</nowiki></code> β {{convert|1200|ft|m|sigfig=1}} Default behavior, for comparison: * <code><nowiki>{{convert|1200|ft|m}}</nowiki></code> β {{convert|1200|ft|m}} Setting {{para|sigfig}} to a value less than 1 is meaningless: * <code><nowiki>{{convert|1200|ft|m|sigfig=0}}</nowiki></code> β {{convert|1200|ft|m|sigfig=0}} {{nay}} ===Round to a multiple of 5: ''15'', ''20'', ''25'', ...=== Using {{para|round|5}} rounds the outcome to a multiple of 5. * <code><nowiki>{{convert|10|m|ft}}</nowiki></code> β {{convert|10|m|ft}} * <code><nowiki>{{convert|10|m|ft|round=5}}</nowiki></code> β {{convert|10|m|ft|round=5}} Similar: using {{para|round|25}} rounds the outcome to a multiple of 25. * <code><nowiki>{{convert|10|m|ft}}</nowiki></code> β {{convert|10|m|ft}} * <code><nowiki>{{convert|10|m|ft|round=25}}</nowiki></code> β {{convert|10|m|ft|round=25}} Default behavior, for comparison: * <code><nowiki>{{convert|10|m|ft|sigfig=4}}</nowiki></code> β {{convert|10|m|ft|sigfig=4}} In a range, one can round ''each value'' individually to the default. Use {{para|round|each}}: * <code><nowiki>{{convert|10 x 200 x 3000|m|ft}}</nowiki></code> β {{convert|10 x 200 x 3000|m|ft}} * <code><nowiki>{{convert|10 x 200 x 3000|m|ft|round=each}}</nowiki></code> β {{convert|10 x 200 x 3000|m|ft|round=each}} ===<span id="Round to a multiple of a given fraction"></span>Round to a multiple of a given fraction: ''{{frac|2|3|16}} inch''=== Specify the desired ''denominator'' using {{para|frac|<some positive integer>}}. ([[Fraction (mathematics)|Denominator]] is the below-the-slash number, for example the 3 in {{frac|1|3}}). * <code><nowiki>{{convert|5.56|cm|in|frac=16}}</nowiki></code> β {{convert|5.56|cm|in|frac=16}} * <code><nowiki>{{convert|8|cm|in|frac=4}}</nowiki></code> β {{convert|8|cm|in|frac=4}} The fraction is reduced when possible: * <code><nowiki>{{convert|8|cm|in|frac=100}}</nowiki></code> β {{convert|8|cm|in|frac=100}} Default behavior uses decimal notation: * <code><nowiki>{{convert|5.56|cm|in}}</nowiki></code> β {{convert|5.56|cm|in}} ===Rounding temperatures: ''Β°C'', ''Β°F'' and ''K''<span class="anchor" id="Rounding temperatures"></span>=== In temperatures, the conversion will be rounded either to the precision comparable to that of the input value or to that which would give three significant figures when expressed in kelvins, whichever is more precise. #{{#invoke:DemoTemplate|convert|10,000|C|F K}} #{{#invoke:DemoTemplate|convert|10,000.1|C|F K}} #{{#invoke:DemoTemplate|convert|-272|C|F K}} #{{#invoke:DemoTemplate|convert|-272|C}} #{{#invoke:DemoTemplate|convert|100|C|F K}} #{{#invoke:DemoTemplate|convert|0|C|F K}} The precision of the input number in example (1) is one digit, but the precision of its kelvins expression is three, so the precision of the Fahrenheit conversion is ''made'' three (made 180...) . (1) and (2) seem to belie the fact that a {{convert|0.1|C-change|F-change|disp=x| is a |abbr=off}}, and make the 32 degrees difference shown in (1) begin to seem off somehow. Result (1) seems off until you set the [[significant figures]] yourself with {{para|sigfig}}: :{{#invoke:DemoTemplate|convert|10000|C|sigfig=5}} or you set the precision ''positionally'', relative to the decimal point (zero being ''at'' the decimal point): :{{#invoke:DemoTemplate|convert|10000|C|0}} The precision of the input number in example (2) is six, so the precision of the Fahrenheit output is six now, whereas before kelvins had determined it to be three. Examples (3) and (4) show how this can be hidden and generate questions, but it occurs there because the kelvins conversion generated the fractional parts. (Before it was the input number that generated the fractional part.) In example (3) the three input digits converted into five significant output digits because of the two digits after the decimal point, generated by the kelvins conversion. This happened again in (5), but in (6) decimal fractions were neither given as input nor induced by the kelvins conversion. ===Rounding input=== There is limited support for rounding the displayed ''input'' number. The rounding takes place ''after'' conversion, so the output is based on the full-precision input. This is useful when the input is produced by {{tlc|#expr:}} or otherwise available to a higher precision than is usefully displayed, and it's desirable to avoid double-rounding. To round the input to a specified number of digits after the decimal point, use one of the parameters: * {{para|adj|ri0}} * {{para|adj|ri1}} * {{para|adj|ri2}} * {{para|adj|ri3}} Note that it is not possible to round above the decimal place ({{para|adj|ri-1}}{{nay}} is invalid). Neither is there support for significant figures, multiples of a number, or any other output-rounding feature. The default precision is computed based on the input, so an explicit output precision must usually be supplied: * {{tlc|convert|4.14159|mi|km|adj{{=}}ri0}} β {{convert|4.14159|mi|km|adj=ri0}} {{nay}} (precisions are mismatched) * {{tlc|convert|4.14159|mi|km|0|adj{{=}}ri0}} β {{convert|4.14159|mi|km|0|adj=ri0}} {{aye}} In this case, if the input were rounded before conversion, a different result would be obtained: * {{tlc|convert|<nowiki>{{#expr:4.14159 round 0}}</nowiki>|mi|km|0}} β {{convert|{{#expr:4.14159 round 0}}|mi|km|0}} {{nay}} (rounds intermediate calculation, giving a different result)
Summary:
Please note that all contributions to Bourbon Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Bourbon Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Toggle limited content width