ފަންވަތް:Rndfrac/doc: Difference between revisions

Content deleted Content added
Created page with "{{Documentation subpage}} This template rounds to a fraction. It takes two parameters. #the number to be rounded (any real number) #the denominator to be rounded to (positive..."
 
m Bot: Replace deprecated <source> tag and "enclose" parameter; cosmetic changes
 
ފޮޅުވަތް 1:
{{Documentation subpage}}
This template rounds to a fraction. It takes two parameters.
#the number to be rounded (any real number)
#the denominator to be rounded to (positive integer)
ފޮޅުވަތް 13:
== Code ==
Main template {{tl|rndfrac}}
<sourcesyntaxhighlight lang="html5">
{{#ifexpr: ( {{{2}}} - 1 ) round 0 = abs( {{{2}}} - 1 )
| {{#ifexpr: {{{1}}} * {{{2}}} round 0 < 0
ފޮޅުވަތް 28:
| {{color | red | This fractional rounding function only accepts positive intergers as the denominator. }}
}}
</syntaxhighlight>
</source>
 
Sub-template {{tl|rndfrac/out}}
<sourcesyntaxhighlight lang="html5">
{{#ifeq: {{{2}}} | 0
| {{{1}}}
ފޮޅުވަތް 37:
| {{{1}}}<sup>&#32;</sup>
}}{{#iferror: {{#expr: 1/{{{4}}} }}
| <sup>{{{2}}}</sup>&frasl;<sub>{{{3}}}</sub>
| <sup>{{#expr: {{{2}}} / {{{4}}} }}</sup>&frasl;<sub>{{#expr: {{{3}}} / {{{4}}} }}</sub>
}}
</span>
}}
</syntaxhighlight>
</source>
 
== See also ==
*{{tl|rnd}}
*{{tl|rndnear}}
*{{tl|dec to frac}}
 
<includeonly>[[Categoryޤިސްމު:Mathematical function templates]]</includeonly>