Template talk:Deg2DMS

Minus signs?
Hyphens for negative values? Even if a minus sign is passed in to the template? Surely should be fixed. Lithopsian (talk) 19:42, 24 August 2020 (UTC)

Template-protected edit request on 13 November 2020
Please change the apostrophe symbols (encoded as ) to correct (angled) &amp;prime; (′) and double-&amp;Prime; (″) symbols, to match e.g. Template:DEC.

More specifically, the code is changed to ° Er... while you're at it, that equation for the seconds is a bit silly. It's more conveniently written as (x*60 - floor(x*60)) * 60 round 3, or in full: °  92.119.17.10 (talk) 00:10, 14 November 2020 (UTC)
 * Yellow check.svg Partly done: The first request is done. For the second, please put the code into the sandbox and create some testcases to show the difference. Thanks. – Jonesey95 (talk) 15:06, 14 November 2020 (UTC)
 * Thank you! For the second edit, here's an example table comparing the output of the two.  (The code above is in Template:X40, and Template:X41 is a comparison helper |-

As you can see, the replacement is equivalent, but shares certain problems with the original (see the 7th, 8th and 9th example below, as well as the last). I can come up with a replacement that fixes everything, but that's a bit more work. Now implemented in Template:X42.

! Input || Deg2DMS || X40 || X42 0.5 0.49 0.499 0.4999 0.49999 0.499999 0.4999999 0.49999999 0.0166666666666666 0.0166666666666667 0.025 0.0249 0.02499 0.024999 0.0249999 0.02499999 1.008333 1.008334 1.0083331 1.0083332 1.0083333 1.0083334 1.0083335 1.0083336 0.9999999999 Any opinions? 92.119.17.10 (talk) 00:05, 16 November 2020 (UTC)
 * + Comparison of old and proposed replacements
 * }
 * The working code, preserved for when Template:X42 gets erased:

°
 * 92.119.17.10 (talk) 00:08, 16 November 2020 (UTC)

Per discussion and examples above, replace the logic with ° This converts the entire angle to seconds and rounds to the specified precision before breaking it apart into degrees and minutes, avoiding certain corner case bugs where the different components would be rounded in different directions, or seconds would be rounded to 60. 92.119.17.10 (talk) 03:31, 16 November 2020 (UTC)
 * Yes check.svg Done looking good. For future information, the best place to sandbox your code is the template's own sandbox, in this case Template:Deg2DMS/sandbox and testing can be done in Template:Deg2DMS/testcases &mdash; Martin (MSGJ · talk) 09:21, 18 November 2020 (UTC)
 * Sorry for the delay in getting to this one; I wanted to test it more thoroughly. It looks like the p parameter is not working properly. See Template:Deg2DMS/testcases. I have put the old template code into the sandbox to show the difference. – Jonesey95 (talk) 15:06, 18 November 2020 (UTC)
 * H'm, the new error is interesting. The problem is not with p proper; it's just that the value 4 happens to trigger a window where the   is revlealing some rounding in the lsbits that is causing a mess.  But rounding the arc seconds before the   is critical to not displaying 60 seconds.  How about just a "redundant" re-rounding after the  ?  I've put that in the sandbox, which seems to work.  There's a comment in the wikisource because it's ugly. 64.44.80.252 (talk) 07:13, 19 November 2020 (UTC)
 * Seems to work, so I have copied it to the live template. I will trust other editors to point out any problems with the new code. The test cases page could use some more examples from real-world use in articles. – Jonesey95 (talk) 17:28, 19 November 2020 (UTC)