Difference between revisions of "Template:Decimal2Base"

From blackwiki
Jump to navigation Jump to search
imported>Jkasd
(add doc)
imported>Toohool
(switch to Lua implementation)
 
Line 1: Line 1:
<includeonly>{{#ifeq:{{#expr: {{{2}}} > 36}}|1|N/A|<!--
+
{{#invoke: BaseConvert | convert
-->{{#ifeq:{{#expr: {{{1}}} > {{#expr: ({{{2}}}^12)-1}} }} | 1 |N/A|<!--
+
  | n={{{1}}}  
-->{{#switch:{{#expr: ({{{1}}} div {{#expr:{{{2}}}^11 }}) mod {{#expr:{{{2}}} }} }}|0={{#ifeq:{{#expr: {{{1}}} > {{#expr:({{{2}}}^12)-1}} }}|1|0}}|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|<!--
+
  | base={{{2}}}
-->10=A|11=B|12=C|13=D|14=E|15=F|16=G|17=H|18=I|19=J|20=K|21=L|22=M|23=N|24=O|25=P|26=Q|27=R|28=S|29=T|30=U|31=V|32=W|33=X|34=Y|35=Z}}<!--
+
}}<noinclude>{{documentation}}</noinclude>
-->{{#switch:{{#expr: ({{{1}}} div {{#expr:{{{2}}}^10 }}) mod {{#expr:{{{2}}} }} }}|0={{#ifeq:{{#expr: {{{1}}} > {{#expr:({{{2}}}^11)-1}} }}|1|0}}|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|<!--
 
-->10=A|11=B|12=C|13=D|14=E|15=F|16=G|17=H|18=I|19=J|20=K|21=L|22=M|23=N|24=O|25=P|26=Q|27=R|28=S|29=T|30=U|31=V|32=W|33=X|34=Y|35=Z}}<!--
 
-->{{#switch:{{#expr: ({{{1}}} div {{#expr:{{{2}}}^9 }}) mod {{#expr:{{{2}}} }} }}|0={{#ifeq:{{#expr: {{{1}}} > {{#expr:({{{2}}}^10)-1}} }}|1|0}}|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|<!--
 
-->10=A|11=B|12=C|13=D|14=E|15=F|16=G|17=H|18=I|19=J|20=K|21=L|22=M|23=N|24=O|25=P|26=Q|27=R|28=S|29=T|30=U|31=V|32=W|33=X|34=Y|35=Z}}<!--
 
-->{{#switch:{{#expr: ({{{1}}} div {{#expr:{{{2}}}^8 }}) mod {{#expr:{{{2}}} }} }}|0={{#ifeq:{{#expr: {{{1}}} > {{#expr:({{{2}}}^9)-1}} }}|1|0}}|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|<!--
 
-->10=A|11=B|12=C|13=D|14=E|15=F|16=G|17=H|18=I|19=J|20=K|21=L|22=M|23=N|24=O|25=P|26=Q|27=R|28=S|29=T|30=U|31=V|32=W|33=X|34=Y|35=Z}}<!--
 
-->{{#switch:{{#expr: ({{{1}}} div {{#expr:{{{2}}}^7 }}) mod {{#expr:{{{2}}} }} }}|0={{#ifeq:{{#expr: {{{1}}} > {{#expr:({{{2}}}^8)-1}} }}|1|0}}|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|<!--
 
-->10=A|11=B|12=C|13=D|14=E|15=F|16=G|17=H|18=I|19=J|20=K|21=L|22=M|23=N|24=O|25=P|26=Q|27=R|28=S|29=T|30=U|31=V|32=W|33=X|34=Y|35=Z}}<!--
 
-->{{#switch:{{#expr: ({{{1}}} div {{#expr:{{{2}}}^6 }}) mod {{#expr:{{{2}}} }} }}|0={{#ifeq:{{#expr: {{{1}}} > {{#expr:({{{2}}}^7)-1}} }}|1|0}}|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|<!--
 
-->10=A|11=B|12=C|13=D|14=E|15=F|16=G|17=H|18=I|19=J|20=K|21=L|22=M|23=N|24=O|25=P|26=Q|27=R|28=S|29=T|30=U|31=V|32=W|33=X|34=Y|35=Z}}<!--
 
-->{{#switch:{{#expr: ({{{1}}} div {{#expr:{{{2}}}^5 }}) mod {{#expr:{{{2}}} }} }}|0={{#ifeq:{{#expr: {{{1}}} > {{#expr:({{{2}}}^6)-1}} }}|1|0}}|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|<!--
 
-->10=A|11=B|12=C|13=D|14=E|15=F|16=G|17=H|18=I|19=J|20=K|21=L|22=M|23=N|24=O|25=P|26=Q|27=R|28=S|29=T|30=U|31=V|32=W|33=X|34=Y|35=Z}}<!--
 
-->{{#switch:{{#expr: ({{{1}}} div {{#expr:{{{2}}}^4 }}) mod {{#expr:{{{2}}} }} }}|0={{#ifeq:{{#expr: {{{1}}} > {{#expr:({{{2}}}^5)-1}} }}|1|0}}|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|<!--
 
-->10=A|11=B|12=C|13=D|14=E|15=F|16=G|17=H|18=I|19=J|20=K|21=L|22=M|23=N|24=O|25=P|26=Q|27=R|28=S|29=T|30=U|31=V|32=W|33=X|34=Y|35=Z}}<!--
 
-->{{#switch:{{#expr: ({{{1}}} div {{#expr:{{{2}}}^3 }}) mod {{#expr:{{{2}}} }} }}|0={{#ifeq:{{#expr: {{{1}}} > {{#expr:({{{2}}}^4)-1}} }}|1|0}}|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|<!--
 
-->10=A|11=B|12=C|13=D|14=E|15=F|16=G|17=H|18=I|19=J|20=K|21=L|22=M|23=N|24=O|25=P|26=Q|27=R|28=S|29=T|30=U|31=V|32=W|33=X|34=Y|35=Z}}<!--
 
-->{{#switch:{{#expr: ({{{1}}} div {{#expr:{{{2}}}^2 }}) mod {{#expr:{{{2}}} }} }}|0={{#ifeq:{{#expr: {{{1}}} > {{#expr:({{{2}}}^3)-1}} }}|1|0}}|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|<!--
 
-->10=A|11=B|12=C|13=D|14=E|15=F|16=G|17=H|18=I|19=J|20=K|21=L|22=M|23=N|24=O|25=P|26=Q|27=R|28=S|29=T|30=U|31=V|32=W|33=X|34=Y|35=Z}}<!--
 
-->{{#switch:{{#expr: ({{{1}}} div {{#expr:{{{2}}} }}) mod {{#expr:{{{2}}} }} }}|0={{#ifeq:{{#expr: {{{1}}} > {{#expr:({{{2}}}^2)-1}} }}|1|0}}|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|<!--
 
-->10=A|11=B|12=C|13=D|14=E|15=F|16=G|17=H|18=I|19=J|20=K|21=L|22=M|23=N|24=O|25=P|26=Q|27=R|28=S|29=T|30=U|31=V|32=W|33=X|34=Y|35=Z}}<!--
 
-->{{#switch:{{#expr: ({{{1}}} div 1) mod {{#expr:{{{2}}} }} }}|0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|<!--
 
-->10=A|11=B|12=C|13=D|14=E|15=F|16=G|17=H|18=I|19=J|20=K|21=L|22=M|23=N|24=O|25=P|26=Q|27=R|28=S|29=T|30=U|31=V|32=W|33=X|34=Y|35=Z}}<!--
 
--><sub>{{{2}}}</sub>}} }}</includeonly><noinclude>{{documentation}}</noinclude>
 

Latest revision as of 05:41, 24 February 2013

{{{1}}}

Template documentation[view] [edit] [history] [purge]

This template converts numbers from decimal to a given base.

Usage

Use: {{Decimal2Base|n|radix}} where n is the number in decimal and radix is the base you want to convert to.

Examples: {{Decimal2Base|42|3}} yields 1120.

{{Decimal2Base|{{#expr: 6 * 9}}|13}} yields 42.

{{Decimal2Base|58|16}} yields 3A.


See also