Template:Val/delimitnum: Difference between revisions

From Zoophilia Wiki
Jump to navigationJump to search
meta>Jimp
allow comma formatting per MOSNUM
meta>Jimp
#ifeq:{{{fmt|gaps}}}|gaps belongs inside #ifexpr:({{{1|0}}}1)=({{{1|0}}}) (the rest is cosmetic)
Line 1: Line 1:
<includeonly><!--
<includeonly><!--  
-->{{#ifeq:{{{fmt|gaps}}}|gaps
    |{{#ifexpr:({{{1|0}}}1)=({{{1|0}}})|<!--  
                 Test loss of precision by appending a fixed digit "1"
                 Test loss of precision by appending a fixed digit "1"
    -->{{FormattingError|Too Many Digits|nocategory={{{nocategory|}}}}}<!--
-->{{#ifexpr:({{{1|0}}}1)=({{{1|0}}})<!--
   -->|<!--      No loss of precision, can display this number
 
    -->{{#ifexpr:{{{1|0}}}<0|&minus;}}<!--  
   -->|<!--      Precision is lost. Display an error message.
  -->{{FormattingError|Too Many Digits|nocategory={{{nocategory|}}}}}<!--
 
  -->|<!--       Precision is not lost. Display the number.
                 Output the mathematical minus sign (not the minus-hyphen) if negative
                 Output the mathematical minus sign (not the minus-hyphen) if negative
    -->{{#ifexpr:abs({{{1|0}}}1)>10*abs({{{1|0}}})|<!--  
  -->{{#ifexpr:{{{1|0}}}<0|&minus;}}<!--
                 Number is an integer (no dot):
 
                 appending a non-zero digit multiplies it by more than 10
                Format according to the parameter fmt.
       -->{{val/delimitnum/whole|{{#expr:abs({{{1|0}}})}}}}<!--  
  -->{{#ifeq:{{{fmt|gaps}}}|gaps<!--
                 Format the integer part using (a) thin space(s) for grouping digits
 
    -->|<!--    Number is not an integer (at least contains a dot)
                Test whether the number is an integer.
      -->{{val/delimitnum/whole|{{#expr:trunc(abs({{{1|0}}}))}}}}.<!--  
                (Appending a non-zero digit multiplies it by more than 10.)
                 Format the integer part using (a) thin space(s) for grouping digits,
    -->|{{#ifexpr:abs({{{1|0}}}9)>10*abs({{{1|0}}})
                followed by the locale's separator before fractional decimals
          |<!--  
                (a decimal point on en-WP)
                 The number is an integer.
      -->{{val/delimitnum/fraction<!--
                Format it using (a) thin space(s) for grouping digits.
        -->|{{#expr:abs({{{1|0}}}1)-trunc(abs({{{1|0}}}1))}}<!--  
                 Do not add a decimal point.
       -->{{val/delimitnum/whole|{{#expr:abs({{{1|0}}})}}}}<!---
 
        -->|<!--
                The number is not an integer.
                Split the number into an integer part an a fractional part.
                 Format the integer part using (a) thin space(s) for grouping digits.
                Add a decimal point.
 
        -->{{val/delimitnum/whole|{{#expr:trunc(abs({{{1|0}}}))}}}}.<!--
 
                 Format the fractional part using (a) thin space(s) for grouping digits.
 
        -->{{val/delimitnum/fraction<!--
          -->|{{#expr:abs({{{1|0}}}1)-trunc(abs({{{1|0}}}1))}}<!--  
                 The fractional part (appended with an extra digit 1  
                 The fractional part (appended with an extra digit 1  
                 to avoid roundoff error on last displayed digit)
                 to avoid roundoff error on last displayed digit)
        -->|{{#expr:(-ln(abs({{{1|0}}}1)-abs({{{1|0}}}))/ln10round 0)-1}}<!--  
          -->|{{#expr:(-ln(abs({{{1|0}}}1)-abs({{{1|0}}}))/ln10round 0)-1}}<!--  
                 The number of decimals to display (the difference of absolute values is
                 The number of decimals to display (the difference of absolute values is
                 the value of the appended digit 1, its log10 gives its position)
                 the value of the appended digit 1, its log10 gives its position)
        -->|nocategory={{{nocategory|}}}<!--  
          -->|nocategory={{{nocategory|}}}<!--  
                 category if formatting error (too many digits)
                 category if formatting error (too many digits)
      -->}}<!--
        -->}}<!--
     -->}}<!--
     -->}}<!--
  -->}}
 
    |{{formatnum:{{{1}}}}}
                Format using commas to the left.
}}</includeonly><noinclude>{{documentation}}</noinclude>
    -->|{{formatnum:{{#expr:abs{{{1}}}}}}}<!--
  -->}}<!--
-->}}</includeonly><noinclude>{{documentation}}</noinclude>

Revision as of 08:29, 17 January 2014