"ढाँचा:Precision" का संशोधनहरू बिचको अन्तर

सा update template name
per talk-page request
पङ्क्ति १:
<noinclude><!--
--============================================================
-- Getprecision - GetCount precisiondecimal ofdigits numberor asin decimalfraction digits(2+1/3)
--============================================================
-- (see NOTES at bottom)
--></noinclude>{{
--
#expr: ( 0 {{
--></noinclude>{{#ifeq: {{{1|15.1230}}}|0|<!--then handle zero
-->{{#exprifexpr: {{str_len{1|0.0000}}}0={{{1|0.00}}0000}}} - 1 <!--|
-1 + <noinclude><!--see NOTE S5--></noinclude>
--> {{#ifexpr: {{{1|0.00}}}+1 > {{{1|0.00}}}1 | - 1}}<!--
--> {{#ifexprswitch: x{{{1|0.000000}}} < 0| - 1}} }}<!--endexpr
|{{padleft:|2|x{{{1}}}}}=1
-->|<!--else determine the
precision-->|{{#exprpadleft: {{str_len|3|x{{{1|15.1230}}}}} <!--=2
--> - |{{Order of magnitudepadleft:|4|x{{{1|15.1230}}} round 0}} - 1 <!--=3
--> |{{#ifexprpadleft: {{{1|15.1230}}}=5|x{{{1|15.1230}}}0 | - 1}}<!--=4
--> |{{#ifexprpadleft: |6|x{{{1|15.1230}}} < 0| - 1}} }}<!--endexpr#=5
|{{padleft:|7|x{{{1|0.0000}}}}}=6
-->}}<noinclude><!--endif {1}=0
|{{padleft:|8|x{{{1}}}}}=7
|{{padleft:|9|x{{{1}}}}}=8
|{{padleft:|10|x{{{1}}}}}=9
|{{padleft:|11|x{{{1}}}}}=10
|{{padleft:|12|x{{{1}}}}}=11
|{{padleft:|13|x{{{1}}}}}=12
|{{padleft:|14|x{{{1}}}}}=13
|{{padleft:|15|x{{{1}}}}}=14
|{{padleft:|16|x{{{1}}}}}=15
|{{padleft:|17|x{{{1}}}}}=16
|{{padleft:|18|x{{{1}}}}}=17
|{{padleft:|19|x{{{1}}}}}=18
|{{padleft:|20|x{{{1}}}}}=19
|{{padleft:|21|x{{{1}}}}}=20
|{{padleft:|22|x{{{1}}}}}=21
|{{padleft:|23|x{{{1}}}}}=22
|{{padleft:|24|x{{{1}}}}}=23
|{{padleft:|25|x{{{1}}}}}=24
|{{padleft:|26|x{{{1}}}}}=25
|{{padleft:|27|x{{{1}}}}}=26
|{{padleft:|28|x{{{1}}}}}=27
|{{padleft:|29|x{{{1}}}}}=28
|{{padleft:|30|x{{{1}}}}}=29
|{{padleft:|31|x{{{1}}}}}=30
|{{padleft:|32|x{{{1}}}}}=31
|{{padleft:|33|x{{{1}}}}}=32
|{{padleft:|34|x{{{1}}}}}=33
|{{padleft:|35|x{{{1}}}}}=34
|{{padleft:|36|x{{{1}}}}}=35
|{{padleft:|37|x{{{1}}}}}=36
|{{padleft:|38|x{{{1}}}}}=37
|{{padleft:|39|x{{{1}}}}}=38
|{{padleft:|40|x{{{1}}}}}=39
|{{padleft:|41|x{{{1}}}}}=40
|#default = 41
}} - floor(
ln (floor( abs({{{1|0}}}) )+0.99 )/ln10 ) - 1
{{#ifexpr: floor(abs({{{1|0}}}) )=0 |-1}}
{{#ifeq: {{{1|0.0000}}}x|0x| + 1}}
|<noinclude><!--else for integers--></noinclude>{{
#ifexpr:{{{1|500}}}=floor({{{1|500}}}/10)*10|-1}}{{
#ifexpr:{{{1|500}}}=floor({{{1|500}}}/100)*100|-1}}{{
#ifexpr:{{{1|500}}}=floor({{{1|500}}}/1E3)*1E3|-1}}{{
#ifexpr:{{{1|500}}}=floor({{{1|500}}}/1E4)*1E4|-1}}{{
#ifexpr:{{{1|500}}}=floor({{{1|500}}}/1E5)*1E5|-1}}{{
#ifexpr:{{{1|500}}}=floor({{{1|500}}}/1E6)*1E6|-1}}{{
#ifexpr:{{{1|500}}}=floor({{{1|500}}}/1E7)*1E7|-1}}{{
#ifexpr:{{{1|500}}}=floor({{{1|500}}}/1E8)*1E8|-1}}{{
#ifexpr:{{{1|500}}}=floor({{{1|500}}}/1E9)*1E9|-1}}{{
#ifexpr:{{{1|500}}}=floor({{{1|500}}}/1E10)*1E10|-1}}{{
#ifexpr:{{{1|500}}}=floor({{{1|500}}}/1E11)*1E11
|-1}}<noinclude><!--
endif {1}0={1} --></noinclude>}}{{
#ifexpr: {{{1|500}}}<0| - 1}}<noinclude><!--For minus sign.
--------------------------------------------------------
Check for fraction "/" to use logn of denominator, by
clearing prior count: (..prior..)*0 + (logn denom / logn 10).
(see NOTE A1). The whole expression ends with close ")".
--></noinclude>{{
#if: {{#titleparts:{{{1|6+3~8}}}|1|2}}| )*0 + (
floor(ln {{#titleparts:{{{1|6+3/8}}}|1|2}} / ln10 - 0.01) +1
}}<noinclude><!--endif fraction
--></noinclude> ) }}<noinclude><!--endexpr# (close paren.)
--
--------------------------------------------------------------
--NOTES:
-- [ These comments are skipped by <noinclude> and not send
-- inside formatted Internet pages, only during edit. ]
--
--NOTE A1: This template determines the precision of a numberdecimals
-- by counting the length of the numeric string, then(in a
-- #switch comparing lengths of padded strings), then
-- subtracting integer length, minus the decimal point if
-- not ansubtracting integer length, minus 1the ifdecimal negative.point,
-- and minus 1 if negative. For integers, 1 place is
-- subtracted for each trailing 0 on the integer.
-- For fractions, any prior count is cleared x 0, then
-- size is logarithm of denominator divided by log 10:
-- (..prior...)*0 + floor(logn denom / logn 10 - .01) + 1.
--
--NOTE D2: The check, for whole integers, compares the amount
Line ३२ ⟶ १०२:
-- check rejects: n = n0 as false; hence n is integer.
--
--NOTE Z3M3: The checkmagnitude onof zerothe forinteger anyportion .00000is compares adding 1calculated
-- by logarithm of the floor of absolute value (divided by
-- [[natural logarithm]] of 10 to adjust for e=2.71828*),
-- as: ln (floor( abs({{{1|-0.050067}}}) )+0.99 )/ln10
-- Function floor(x) trims the decimal part, to leave the
-- whole count: 0-9 yield 0, 10-19 as 1, 1000-1999 as 3.
-- The abs(x) avoids floor of negatives, floor(-0.1)= -1,
-- hence using abs(x) ensures -0.1 floors to 0 not -1.
-- Near zero, the +0.99 avoids invalid log of 0, but does
-- not round-up any decimals, already floored as nnn.00.
-- Complexity is 6 operations: floor of abs( {1} ) +0.99
-- then logn div logn10, then floor that logarithm ratio.
-- Decimals -1 < x < 1 yield -1, avoiding log 0.001 = -3.
--
--NOTE N4: Nesting of if-else and nested templates is kept to
-- a minimum, due to the MediaWiki 1.6 limit of 40 levels
-- of if-logic for all nested templates used together.
-- Template {ordomag} was omitted to avoid 2 more levels
-- of nested templates. Template {Precision} had 8 levels,
-- and this template was trimmed to only 5 levels.
--
--NOTE S5: The #switch is run with "x" prepended in front of
-- the amount, otherwise a #switch will compare as numeric
-- where "2" would match "2.0" even though "2" is length 1
-- so "x2" no longer matches with "x2.0" as non-numeric.
-- The #switch will exit on the first match, so smaller
-- lengths are compared first, to avoid extra comparisons
-- for more rare, longer numeric strings up to 41 long.
--
--NOTE W6: The check for integers with whole end-zeroes uses
-- typical n=n/10*10, for each power of 10, where whole
-- millions match: {{#ifexpr: {1}=floor( {1}/1E6 )*1E6| }}
-- Previously, {Precision} had tried to use "round" to
-- detect end-zeroes but "round" loses precision at -5,
-- so, n00000 round -5 differs from n00000 slightly, and
-- comparisons to exact rounded amounts failed to match
-- some numbers when 6 or more zeroes "n000000".
--
--NOTE Z7: The check on zero for any .00000 compares adding 1
-- to the amount, versus appending "1" at the end: if the
-- amount is a decimal, then adding 1 will be larger than
Line ४० ⟶ १४८:
-- rejects: 0+1 > 01 as false; hence whole 0 is integer.
--
-- WARNING: *** DO NOT DELETE COMMENTS FROM THIS TEMPLATE ***
-- Unless these comments are readily available, people
-- might tinker with the coding (or rename templates),
-- in hopes to clarify operation because these comments
-- were not nearby to explain the issues. Having these
-- comments only on a doc-page increases the danger of
-- explanations no longer matching the current coding.
-- UPDATE these comments to match changes to the template.
-- UPDATE the HISTORY during major changes (not typos).
--
---------------------------------------------------------------
--HISTORY:
--15Aug10 Created to get precision even if large or negative.
Line ४९ ⟶ १६६:
--04Sep10 Fixed to handle decimals between 0~1 (by round 0).
--04Sep10 Updated NOTES to explain the check appending 0 or 1.
--03Jan11 Fix integer end-zeroes: 50 as -1, 500 as -2, 5000 -3.
--03Jan11 Omit {Order of Magnitude} for 2 levels less nesting.
--03Jan11 Omit {Str_len} for 8 fewer levels of 40-nest limit.
--03Jan11 Put "noinclude" around all inter-line HTML comments.
--03Jan11 Allow fraction "/": floor(logn denom/logn 10 -.01)+1.
--
-->{{documentation}}</noinclude>
"https://ne.wikipedia.org/wiki/ढाँचा:Precision" बाट अनुप्रेषित