Difference between revisions of "Template:Fraction"

From blackwiki
Jump to navigation Jump to search
imported>Thesevenseas
(Optimised Code)
imported>Crissov
m (make it actually do what the docu says it does)
Line 1: Line 1:
 
<span class="template-frac"><noinclude><!--
 
<span class="template-frac"><noinclude><!--
 
--></noinclude>{{#if:{{{3|}}}
 
--></noinclude>{{#if:{{{3|}}}
                |{{{1}}}&thinsp;{{#switch:{{{3}}}
+
    |{{{1}}}&thinsp;{{#switch:{{{3}}}
                                |2 = {{#ifeq:{{{2}}}|1
+
        |2 = {{#ifeq:{{{2}}}|1
                                     
+
           
                                      |#default=<sup>{{{2}}}</sup>&frasl;<sub>{{{3}}}</sub>
+
            |#default={{{2}}}{{{3}}}
                                      }}
+
          }}
                                |3 = {{#switch:{{{2}}}
+
        |3 = {{#switch:{{{2}}}
                                      |1=⅓
+
            |1=⅓
                                      |2=⅔
+
            |2=⅔
                                      |#default=<sup>{{{2}}}</sup>&frasl;<sub>{{{3}}}</sub>
+
            |#default={{{2}}}{{{3}}}
                                      }}
+
          }}
                                |4 = {{#switch:{{{2}}}
+
        |4 = {{#switch:{{{2}}}
                                      |1=¼
+
            |1=¼
                                      |2=½
+
            |2=½
                                      |3=¾
+
            |3=¾
                                      |#default=<sup>{{{2}}}</sup>&frasl;<sub>{{{3}}}</sub>
+
            |#default={{{2}}}{{{3}}}
                                      }}
+
          }}
                                |5 = {{#switch:{{{2}}}
+
        |5 = {{#switch:{{{2}}}
                                      |1=⅕
+
            |1=⅕
                                      |2=⅖
+
            |2=⅖
                                      |3=⅗
+
            |3=⅗
                                      |4=⅘
+
            |4=⅘
                                      |#default=<sup>{{{2}}}</sup>&frasl;<sub>{{{3}}}</sub>
+
            |#default={{{2}}}{{{3}}}
                                      }}
+
          }}
                                |6 = {{#switch:{{{2}}}
+
        |6 = {{#switch:{{{2}}}
                                      |1=⅙
+
            |1=⅙
                                      |2=⅓
+
            |2=⅓
                                      |3=½
+
            |3=½
                                      |4=⅔
+
            |4=⅔
                                      |5=⅚
+
            |5=⅚
                                      |#default=<sup>{{{2}}}</sup>&frasl;<sub>{{{3}}}</sub>
+
            |#default={{{2}}}{{{3}}}
                                      }}
+
          }}
                                |8 = {{#switch:{{{2}}}
+
        |8 = {{#switch:{{{2}}}
                                      |1=⅛
+
            |1=⅛
                                      |2=¼
+
            |2=¼
                                      |3=⅜
+
            |3=⅜
                                      |4=½
+
            |4=½
                                      |5=⅝
+
            |5=⅝
                                      |6=¾
+
            |6=¾
                                      |7=⅞
+
            |7=⅞
                                      |#default=<sup>{{{2}}}</sup>&frasl;<sub>{{{3}}}</sub>
+
            |#default={{{2}}}{{{3}}}
                                      }}
+
          }}
                                |#default=<sup>{{{2}}}</sup>&frasl;<sub>{{{3}}}</sub>
+
        |#default={{{2}}}{{{3}}}
                                }}
+
        }}
                |{{#if:{{{2|}}}
+
    |{{#if:{{{2|}}}
                  |{{#switch:{{{2}}}
+
      |{{#switch:{{{2}}}
                    |2 = {{#ifeq:{{{1}}}|1
+
    |2 = {{#ifeq:{{{1}}}|1
                         
+
       
                          |#default=<sup>{{{1}}}</sup>&frasl;<sub>{{{2}}}</sub>
+
        |#default={{{1}}}{{{2}}}
                        }}
+
      }}
                    |3 = {{#switch:{{{1}}}
+
    |3 = {{#switch:{{{1}}}
                          |1=⅓
+
        |1=⅓
                          |2=⅔
+
        |2=⅔
                          |#default=<sup>{{{1}}}</sup>&frasl;<sub>{{{2}}}</sub>
+
        |#default={{{1}}}{{{2}}}
                        }}
+
      }}
                    |4 = {{#switch:{{{1}}}
+
    |4 = {{#switch:{{{1}}}
                          |1=¼
+
        |1=¼
                          |2=½
+
        |2=½
                          |3=¾
+
        |3=¾
                          |#default=<sup>{{{1}}}</sup>&frasl;<sub>{{{2}}}</sub>
+
        |#default={{{1}}}{{{2}}}
                        }}
+
      }}
                    |5 = {{#switch:{{{1}}}
+
    |5 = {{#switch:{{{1}}}
                          |1=⅕
+
        |1=⅕
                          |2=⅖
+
        |2=⅖
                          |3=⅗
+
        |3=⅗
                          |4=⅘
+
        |4=⅘
                          |#default=<sup>{{{1}}}</sup>&frasl;<sub>{{{2}}}</sub>
+
        |#default={{{1}}}{{{2}}}
                        }}
+
      }}
                    |6 = {{#switch:{{{1}}}
+
    |6 = {{#switch:{{{1}}}
                          |1=⅙
+
        |1=⅙
                          |2=⅓
+
        |2=⅓
                          |3=½
+
        |3=½
                          |4=⅔
+
        |4=⅔
                          |5=⅚
+
        |5=⅚
                          |#default=<sup>{{{1}}}</sup>&frasl;<sub>{{{2}}}</sub>
+
        |#default={{{1}}}{{{2}}}
                        }}
+
      }}
                    |8 = {{#switch:{{{1}}}
+
    |8 = {{#switch:{{{1}}}
                          |1=⅛
+
        |1=⅛
                          |2=¼
+
        |2=¼
                          |3=⅜
+
        |3=⅜
                          |4=½
+
        |4=½
                          |5=⅝
+
        |5=⅝
                          |6=¾
+
        |6=¾
                          |7=⅞
+
        |7=⅞
                          |#default=<sup>{{{1}}}</sup>&frasl;<sub>{{{2}}}</sub>
+
        |#default={{{1}}}{{{2}}}
                        }}
+
      }}
                    |#default=<sup>{{{1}}}</sup>&frasl;<sub>{{{2}}}</sub>
+
    |#default={{{1}}}{{{2}}}
                  }}
+
      }}
                  |{{#switch:{{{1}}}
+
      |{{#switch:{{{1}}}
                    |2=½
+
    |2=½
                    |3=⅓
+
    |3=⅓
                    |4=¼
+
    |4=¼
                    |5=⅕
+
    |5=⅕
                    |6=⅙
+
    |6=⅙
                    |8=⅛
+
    |8=⅛
                    |#default=<noinclude>[[Division by zero|</noinclude><sup>1</sup>&frasl;<sub>{{{1<noinclude>|0</noinclude>}}}</sub><noinclude>]]</noinclude>
+
    |#default={{{1|x}}}
                  }}
+
      }}
                }}
+
    }}
          }}</span><noinclude>
+
    }}</span><noinclude>
 
{{Documentation}}
 
{{Documentation}}
 
</noinclude>
 
</noinclude>

Revision as of 23:45, 3 October 2010

⅟x

Template documentation[create]