Template talk:Round

message: 04-April-2010: The rounding Template:Rnd can be condensed by merging the short contents of subtemplate  and avoid an extra level of nested subtemplates. Removing 1 more nest-level can help avoid hitting Wikipedia's template-nesting limit. Rnd can be changed to directly invoke ,  or  without using the "middle-man" Template:Rnd/a. The condensed template would be identical to Rnd invoking Rnd/a, but avoids the 2-step transclusion by combining expressions formerly split between the 2 templates. As shown by the template contents, below, the proposed version of {Rnd} would be similar in size to combining the text of the former {Rnd} with {Rnd/a}.
The proposed Template:Rnd replaces former Template:Rnd & Template:Rnd/a combined, as just one level of nesting to perform the same steps.
----
Template:Rnd: (proposed version)
: 
: 
: 
----
Template:Rnd: (former version)
: 
: 
: 
: 
----
Template:Rnd/a:  (formerly used)
: 
: 
: 
: 
As shown above, the proposed contents of Template:Rnd would be similar in size to combining the text of the two templates, since the joining of the 2 allows combining the 3 {#expr} expressions, which, formerly, had been split between the 2 templates. The supposed efficiency of passing common parameters, into Rnd/a, had been offset by the inefficiency of comparing those parameters in multiple expressions, which had been split between the 2 templates. By re-combining the 2 templates, the split expressions can be re-combined, and hence the reduced template is also efficient. There had been no real improvement by splitting into {Rnd/a}, but fortunately, recombining {Rnd/a} into {Rnd} is a simple change. -Wikid77 (talk) 15:56, 4 April 2010 (UTC)
thread_title: Condensing Rnd by combining Rnd/a

message: 05-April-2010: The rounding Template:Rnd needs to be replaced from the Template:Rnd/sandbox to combine the contents of  and allow that subtemplate to be bypassed, as 1 less nesting level against the Wikipedia template-nesting limit. IMPACT: nearly 307,000 pages will be reformatted, with over 286,000 using {Convert}, while the other pages use rounding in other calculations.
The condensed template contents are shown below:
Template:Rnd/sandbox: (proposed version)
: 
: 
: 
After update, then Template:Rnd/a should become almost totally unused, as in what-links-here for {Rnd/a}. The table below shows the before-and-after results as identical, with every digit exactly the same after the update, but just rounded using 1 template to begin rounding, rather than 2 nested templates:
Example              	Current Rnd	Proposed Rnd/sandbox
          	           	
    	           	
    	           	
    	           	
          	           	
          	           	
    	           	
    	           	
    	           	
   	           	
   	           	
   	           	
	           	
 	           	
 	           	
 	           	
 	           	
 	           	
 	           	
 	           	
 	           	
	           	
	           	
	           	
       	           	
Once Template:Rnd has been updated, the table above should appear unchanged, because all of the rounded amounts will be rounded in exactly the same manner as before, with every digit exactly the same, but rounded using 1 less subtemplate, in over 307,000 calculations. -Wikid77 00:31, 5 April 2010 (UTC)
replies: text: Looks like the change has not produced any errors  Ronhjones  (Talk) 00:50, 5 April 2010 (UTC)
thread_title: Change Rnd to bypass Rnd/a

message: When the template was created we had to deal with pre-expand limits.  This (in part) explains the design.  Nesting several levels of small templates allowed us to achieve a very low pre-expand size whereas a tree of nested ifs might have caused strife.  Improvements have since been made and we no longer have to worry about the size of stuff which doesn't get included.  This has shifted the focus towards another limit we (still) have to deal with: template nesting.  This is what Wikid is talking about above.
I've written a version in the sandbox which uses an elaborate if tree to bypass the level c subtemplates (, , etc.).  We could bypass the b level too, this would involve repeating the round function several times but according to the above discussion it would seem to be worth it. JIMp talk·cont 06:31, 16 February 2012 (UTC)
thread_title: Bypassing the b & c (& d) subtemplates too

message: As noted on the convert talk page  is broken.  These should both give "6".


The first (used by ) is not working properly (giving "4").  Luckily the second is working.
Here's the new code for  (it goes beyond the page).

Let's fix  whilst were're at it (just change the /10^5 to a *10^-5).
JIMp talk·cont 09:21, 12 November 2010 (UTC)
replies: text: rnd/b1 done, for rnd/b-1, do both /10^5 need to become *10^-5, or just the last one ? —TheDJ (talk • contribs) 14:26, 12 November 2010 (UTC)
replies: text: It seems only the last one is causing the problem ... but who knows ...
Another thing: The template is (still) misbehaving in infoboxes; this was actually the problem that lead me here in the first place.  I'm hoping to try some things out which will involve a rewrite of the main page and of . JIMp talk·cont 14:46, 12 November 2010 (UTC)

text: Could you carry out tests on Template:Rnd/sandbox rather than the live template? — Martin (MSGJ · talk) 16:55, 12 November 2010 (UTC)
replies: text: Yes and no.  We can test the code in the sandbox and see how this template goes but we won't know whether it fixes the convert-infobox clash until it's running. JIMp talk·cont 17:00, 12 November 2010 (UTC)
replies: text: ... It's now in the sandbox & everything looks fine (see the table above). JIMp talk·cont 17:07, 12 November 2010 (UTC)
replies: text: Okay, I made the change, but it didn't fix the transclusion depth issue, so I reverted it for now.  If this wasn't supposed to fix this issue, let me know and I can re-implement it.  Thanks! Plastikspork ―Œ(talk) 16:54, 13 November 2010 (UTC)
replies: text: Whilst it was running did you see anything happen to the horrible red mess over there? JIMp talk·cont 10:40, 14 November 2010 (UTC)
replies: text: No, there was no change in the red mess in the infobox there floating on the right.  It also didn't appear to break anything, so I can reimplement it if you want. By the way, I just added another example, to expose the nature of the infobox problem.  Basically, each call to  adds two to the transclusion depth.  When the infobox is within another template, that adds one as well.  So, at level 2 and 4, everything is fine, but when we jump to over 4, it breaks. Plastikspork ―Œ(talk) 17:58, 14 November 2010 (UTC)

text: Thanks.  This will be useful info in trying to get this working. JIMp talk·cont 10:40, 14 November 2010 (UTC)
replies: text: I made the change.--Patrick (talk) 00:45, 16 November 2010 (UTC)
thread_title: Ifexpr error causing strife

message: Reminder: The template-nesting can be reduced by specifying precision in Convert, rather than the default which invokes the nested templates to determine precision. Notice, in the examples, below, how the errors were avoided when precision was specified as round "0" or "sigfig=5" and such.

{{Infobox power station
|name           = Use {convert{{!}}12344{{!}}m3}
| installed_capacity = {{convert|12344|m3}}
}}
{{Infobox power station
|name           = Use {convert{{!}}12344{{!}}m3{{!}}0}
| installed_capacity = {{convert|12344|m3|0}}
}}
{{Infobox power station
|name           = Use {convert{{!}}12344{{!}}m3{{!}}sigfig=5}
| installed_capacity = {{convert|12344|m3|sigfig=5}}
}}

Sometimes, it is faster to hard-code the precision for certain cases, rather than try to redesign and modify the {Precision} or {Rnd} templates and risk upsetting 310,000 other articles. If people, in general, always put "0" or "sigfig=3" (or similar), then those conversions will be faster and bypass the {Precision} templates completely.
I initiated the prior update to {Rnd} to bypass {Rnd/a} and directly invoke {Rnd/b*} because that uses 1 fewer template in the 40-deep limit. The usage figures revealed that {Rnd/a}, no longer transcluded, was dropped from 308,000 articles (after a few days). However, we need to get the developers to raise the template-nesting limit to 100 (or 60 or such). Convert is complex, but this is "not Rocket Science" and we need at least 50-deep nesting to expand Convert and other templates for validation and error-message subtemplates. You might know the 40 limit is pathetic, similar to a "call stack" limited to only 40 procedures (subroutines) nested. In modern times, call-stack depth is almost unlimited, so 100 (or 200 or 500) would be more reasonable. However, there might be some issues of "efficiency" which would limit depth to 60 as less of a resource drain. The MediaWiki software has been so peculiar, and concepts of modern software might not apply, except beware that many software developers have fragile egos caused by the strain of all the details being juggled in a nightmare of total software they didn't all write. -Wikid77 (talk) 13:23, 15 November 2010 (UTC)
thread_title: Avoid errors by setting precision

message: I'm cheating, I know, but I think I've got rid of those error messages.  Getting garbage in the second parameter was the cause.  Now I tweeked the template to round to two significant figures in this case.  Of course, the real solution is fixing  but before we can get  in order we have to get this one working smoothly. JIMp talk·cont 07:07, 21 February 2012 (UTC)
thread_title: A hack

message: I've created three new rounding templates.
* for rounding to a fraction
* for rounding to a multiple
* for formatting using gaps
JIMp talk·cont 17:08, 21 February 2012 (UTC)
thread_title: New templates

message: I created  which invokes Lua to make this template much faster.  The output at template:rnd/testcases seems to be identical to the current , except for very long numbers where the truncation is slightly different, but I would appreciate another set of eyes to make sure.  Dragons flight (talk) 21:20, 21 February 2013 (UTC)
replies: text: Is is possible this change is the cause of the widespread errors I'm seeing with automatic population density in ?  (See Template talk:Infobox settlement#Problem_with_auto_density). If so, perhaps a revert is in order. —Stepheng3 (talk) 23:14, 22 February 2013 (UTC)
replies: text: I rolled back the change, can you provide information about what case is actually breaking?  Dragons flight (talk) 23:18, 22 February 2013 (UTC)
replies: text: The relevant invocations of  are buried down in the population density calculations of  which I believe are performed in .  Articles affected included Calistoga, California.  The revert seems to have cleared up the problem, btw. —Stepheng3 (talk) 23:25, 22 February 2013 (UTC)

text:  This page showed errors in all "Result" columns of the first two tables before the changes were reverted. --hydrox (talk) 23:30, 22 February 2013 (UTC)
replies: text: I've setup a testbed using User:Stepheng3/sandbox, Template:Infobox settlement/sandbox, Template:Infobox settlement/densdisp/sandbox, and Template:Rnd/sandbox in order to recreate the problem. —Stepheng3 (talk) 23:43, 22 February 2013 (UTC)
replies: text:  needs expert attention before it will work with the new version of .  Please stand by... —Stepheng3 (talk) 02:46, 23 February 2013 (UTC)
thread_title: Lua implementation

message: •This template never should have been named "rnd", but "round". (Too terse - I have never rnded a number in my life.) ("rnd()" is the random number generator function in some older programming languages.) Trying to find an excuse for {rnd}: Compactness at the expense of unclarity? Fetish/prfrnce for cprtc tmplt names?
•Template:Round existed since 2006-04-16. Template:Decimals existed since 2006-12-07. Despite this, Jimp created Template:Rnd on 2007-09-21. Trying to find an excuse for this addition: Didn't know and didn't look? Chose to skip the sandbox and red tape, to get the alternate implementation out there?
Both templates refer other templates for retaining trailing zeros. The names derived differently.  → −123.00;  → 123.00
{rnd} is "beating" (round} (not that that proves anything), but {decimals} is beating {rnd/-}:
*Template:Rnd has 245,834 transclusions (and is "protected") and Template:Rnd/- has 440 (and is not "protected" at all).
*Template:Round has only 7,022 (and is only semi-protected) and Template:Decimals has 12,804 transclusions (and is "protected").
A way out is a little harsh, but might go smoothly: 0) Compare codes, in case improvement to {rnd} is possible. 1) Replace {round} with this [compatible] code. 2) Redirct {rnd} to {round}. (Because I prefer {round}, I urge to NOT redirect the minority {round} to (rnd}.) -A876 (talk) 17:02, 20 November 2017 (UTC)
thread_title: Should not be "round" not "rnd"; "rnd" is redundant duplication

message: Please add  inside . — JJMC89 (T·C) 07:17, 15 December 2018 (UTC)
replies: text: ~  Amory (u • t • c) 10:40, 15 December 2018 (UTC)
thread_title:  Nominated for merging: [[Wikipedia:Templates for discussion/Log/2018 December 14#Template:Rnd]] 

message: Please replace the contents of this template with the contents of the sandbox in order to remove an undesirable line break that is causing Linter missing end tag / stripped tag errors. See User:Jonesey95/sandbox3 for an example. Thanks. – Jonesey95 (talk) 14:23, 15 December 2018 (UTC)
replies: text: Pinging , if you are around. Thanks. – Jonesey95 (talk) 14:24, 15 December 2018 (UTC)

text: Done Yeah, that's on me, window size hid the newline.  Thanks. ~  Amory (u • t • c) 15:15, 15 December 2018 (UTC)
thread_title:  Protected edit request on 15 December 2018 

message: See the auto-rounded version of DnuCs in the table at Template:Physical constants/doc: .  Basically, the output of  was being fed to , and for that constant, the value is 10 digits long (9192631770), and the resultant exponential notation () was not valid input to .
I fixed it by changing  to use {{#expr:{ round }} rather than use a more complex pretty-printer like  at all.  But since you're doing the conversion and are familiar with the whole thing, you might want to take a look. 167.88.12.231 (talk) 02:54, 2 June 2019 (UTC)
replies: text: I could have sworn I had looked at all of the templates calling Template:Decimals and checked for any cases like this before doing the redirection after the merge was reverted two months ago because Template:Inflation broke in exactly the same way. I probably missed this one because of the large amount of markup between the decimals and the rounding template. Note to self: Merging templates is harder than you think ... * Pppery * it has begun... 03:08, 2 June 2019 (UTC)
thread_title:  Merge with [[Template:decimals]] broke [[Template:Physical constants]] 

message: Can :Category:Pages with bad rounding precision show only article-space? , another one. Thanks. MB 02:56, 19 November 2019 (UTC)
replies: text: . – Jonesey95 (talk) 17:49, 19 November 2019 (UTC)
thread_title:  Error cat 

message: Why is it not mentioned anywhere in the documentation that  supports mathematical expressions?
: → 
: → 
I have learned about the existence of this functionality from the source code of . — UnladenSwallow (talk) 23:13, 11 July 2021 (UTC)
thread_title:  Math expressions