https://wiktenauer.com/index.php?title=Template:Convert/numdisp&feed=atom&action=historyTemplate:Convert/numdisp - Revision history2024-03-29T11:26:31ZRevision history for this page on the wikiMediaWiki 1.34.2https://wiktenauer.com/index.php?title=Template:Convert/numdisp&diff=15783&oldid=prevMichael Chidester: 1 revision2012-09-23T02:21:32Z<p>1 revision</p>
<p><b>New page</b></p><div><noinclude><!--<br />
--============================================================<br />
-- Display a number, with optional fraction part: 6+3/8<br />
--============================================================<br />
-- (see NOTES at bottom)<br />
--<br />
--></noinclude>{{#if:{{#titleparts:{{{1|-1200-3~118}}}|1|2}}<br />
|{{Convert/numdisp/frac<br />
|{{{1|-1200-3/118}}}|{{#titleparts:{{{1|-1200-3/118}}}|1|1}}|{{#titleparts:{{{1|-1200-3/118}}}|1|2}}}}<!--split at "/"<br />
--else-->|{{#ifexpr:{{{1|-14000.00}}} < 0<br />
|<!--then re-build negative number (see NOTE Z4 below)<br />
-->{{formatnum:<br />
{{padright:−<!--&minus-->{{#expr:-{{{1|-14000.00}}} }}<!--endexpr<br />
--put decimal if needed-->{{<br />
#ifexpr:{{{1|-14000.00}}}0={{{1|-14000.00}}}<br />
and {{{1|-14000.00}}}=floor( {{{1|-14000.00}}} )|.}}<!--<br />
-->|{{strlen_short|{{{1|-14000.00}}}|}}<!--endstrlen_short<br />
-->|0}}<!--endpadright end-zeroes "0" to original length<br />
-->}}<!--endformatnum<br />
else-->|{{formatnum: {{{1|6000.500}}} }}}}<!--endif {1}<0<br />
-->}}<noinclude><!--endif {#titleparts..}<br />
--------------------------------------------------------------<br />
--NOTES:<br />
-- [ These comments are skipped by <noinclude> and not sent<br />
-- in formatted Internet pages, only during edit. ]<br />
--<br />
--NOTE A1: This template processes a number, for display, by<br />
-- checking to display a fraction part ("/"), else it<br />
-- will check for negative to display a unicode &minus<br />
-- and {{formatnum:{{#expr:abs( {{{1|-6000}}} )}}}} such<br />
-- as "-6000" with a full minus sign rather than hyphen.<br />
-- In 99% of Wikipedia usage, there are no fractions.<br />
--<br />
--NOTE D2: The check, for fraction parts, uses parser-function<br />
-- #titleparts to split the number at "/" (if any) and<br />
-- then checks part 2 (the denominator, after the slash)<br />
-- to trigger use of {{Convert/numdisp/fracparts}}. Hence,<br />
-- #if: {{#titleparts:{{{1|6+3/8}}}|1|2}}<br />
-- will be true if a denominator exists (such as "8").<br />
--<br />
--NOTE N3: This template uses minimal expansion depth of the<br />
-- if-else logic by checking for "/" before invoking the<br />
-- nested subtemplate {{Convert/numdisp/fracparts}}. The<br />
-- check for a negative number increases the nesting depth<br />
-- by 1 level to apply abs({1}) in a nested {#expr:} parser<br />
-- function, to use the absolute value of the amount {1}.<br />
--<br />
--NOTE Z4: Any end-zeroes on a decimal are preserved by not<br />
-- using positive amounts in an expression, and for rare<br />
-- negative amounts, the &minus with inverse -{1} is padded<br />
-- by {padright:} with end-zeroes "0" to {strlen_short} but<br />
-- uses #ifexpr:{1}0={1} and floor({1})={1} to put ".".<br />
-- So, {strlen_short} keeps minimal expansion depth of +2.<br />
--<br />
-- WARNING: *** DO NOT DELETE COMMENTS FROM THIS TEMPLATE ***<br />
-- Unless these comments are readily available, people<br />
-- might tinker with the coding (or rename templates),<br />
-- in hopes to clarify operation because these comments<br />
-- were not nearby to explain the issues. Having these<br />
-- comments only on a doc-page increases the danger of<br />
-- explanations no longer matching the current coding.<br />
-- UPDATE these comments to match changes to the template.<br />
-- UPDATE the HISTORY during major changes (not typos).<br />
--<br />
--------------------------------------------------------------<br />
--HISTORY:<br />
--03Apr09 Created by [[User:Jimp]] on English Wikipedia.<br />
--19Nov10 Invokes subtemplate only if has denominator (at "/").<br />
--19Nov10 Put NOTES comments to explain template coding.<br />
--19Nov10 Put HISTORY comments to log major changes.<br />
--19Nov10 Put all parameters on 1 line to avoid newline "2^ /3"<br />
--20Nov10 Linked {Documentation} to hold any interwiki links.<br />
--12Feb11 Shows Unicode &minus ("−") for negative numbers.<br />
--17Feb11 Used {padright:} to re-add end-zeroes on negatives.<br />
--17Feb11 Used #ifexpr:{1}0={1} and floor({1})={1}, to put "."<br />
--<br />
** Add interwiki links to /doc subpage to avoid changes here **<br />
--<br />
-->{{Documentation}}<br />
</noinclude></div>Michael Chidester