Difference between revisions of "Template:Deg2DMS"
imported>MSGJ (improved formulae requested by 92.119.17.10) |
imported>Jonesey95 (fix precision bug via sandbox copy (may not be the most elegant, but it seems to work)) |
||
| Line 1: | Line 1: | ||
| − | + | {{#expr: trunc(({{{1|0}}} * 3600 round {{#if:{{{p|}}}|{{{p|}}}|3}}) / 3600)}}° <!-- | |
| − | |||
-->{{#expr: trunc(({{{1|0}}} * 3600 round {{#if:{{{p|}}}|{{{p|}}}|3}}) mod 3600 / 60)}}{{#if:{{{sup|}}}|<sup>m</sup>|′}} <!-- | -->{{#expr: trunc(({{{1|0}}} * 3600 round {{#if:{{{p|}}}|{{{p|}}}|3}}) mod 3600 / 60)}}{{#if:{{{sup|}}}|<sup>m</sup>|′}} <!-- | ||
| − | -->{{#expr: ({{{1|0}}} * 3600 round {{#if:{{{p|}}}|{{{p|}}}|3}}) fmod 60}}{{#if:{{{sup|}}}|<sup>s</sup>|″}}<noinclude> | + | -->{{#expr: ({{{1|0}}} * 3600 round {{#if:{{{p|}}}|{{{p|}}}|3}}) fmod 60 round {{#if:{{{p|}}}|{{{p|}}}|3}}}}{{#if:{{{sup|}}}|<sup>s</sup>|″}}<noinclude> |
| + | <!--"Redundant" double rounding is required to eliminate all artifacts.--> | ||
{{Documentation}} | {{Documentation}} | ||
</noinclude> | </noinclude> | ||
Latest revision as of 17:27, 19 November 2020
0° 0′ 0″
| This template is used on approximately 3,200 pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them.
Transclusion count updated automatically (see documentation). |
Description
This template converts a positive decimal degree value to degrees° minutes' seconds'' format or to degrees° minutesm secondss format (the degree symbol ° is invariant between the two formats).
Usage
{{Deg2DMS|positive decimal degrees|p=precision|sup=ms}}.
Parameter p is optional and defaults to 3. It is the number of decimal digits that the seconds are rounded to.
Parameter sup is optional and changes the default apostrophe-format for arcminutes and arcseconds (1° 2′ 3″) to the m-s-format for arcminutes and arcseconds (1° 2m 3s). Any non-blank value has this effect, but using |sup=ms is customary.
For example:
{{Deg2DMS|266.416837}} returns 266° 25′ 0.613″.
{{Deg2DMS|266.416837|p=4}} returns 266° 25′ 0.6132″.
{{Deg2DMS|266.416837|p=4|sup= }} returns 266° 25′ 0.6132″.
{{Deg2DMS|266.416837|p=4|sup=ms}} returns 266° 25m 0.6132s.
{{Deg2DMS|266.416837|p=4|sup=no}} returns 266° 25m 0.6132s.
{{Deg2DMS|266.416837|p=4|sup=''}} returns 266° 25m 0.6132s.
See also
| The above documentation is transcluded from Template:Deg2DMS/doc. (edit | history) Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages. Please add categories to the /doc subpage. Subpages of this template. |