Difference between revisions of "Template:Hex2dec/2"

From blackwiki
Jump to navigation Jump to search
imported>Plastikspork
(rv for now)
imported>Ludwigs2
Line 1: Line 1:
{{#switch:{{uc:{{padleft:|{{#expr:{{{2|0}}}+1}}|{{{1|}}}}}}}|{{padleft:|{{{2|0}}}|{{{1|}}}}}0=0|{{padleft:|{{{2|0}}}|{{{1|}}}}}1=1|{{padleft:|{{{2|0}}}|{{{1|}}}}}2=2|{{padleft:|{{{2|0}}}|{{{1|}}}}}3=3|{{padleft:|{{{2|0}}}|{{{1|}}}}}4=4|{{padleft:|{{{2|0}}}|{{{1|}}}}}5=5|{{padleft:|{{{2|0}}}|{{{1|}}}}}6=6|{{padleft:|{{{2|0}}}|{{{1|}}}}}7=7|{{padleft:|{{{2|0}}}|{{{1|}}}}}8=8|{{padleft:|{{{2|0}}}|{{{1|}}}}}9=9|{{padleft:|{{{2|0}}}|{{{1|}}}}}A=10|{{padleft:|{{{2|0}}}|{{{1|}}}}}B=11|{{padleft:|{{{2|0}}}|{{{1|}}}}}C=12|{{padleft:|{{{2|0}}}|{{{1|}}}}}D=13|{{padleft:|{{{2|0}}}|{{{1|}}}}}E=14|{{padleft:|{{{2|0}}}|{{{1|}}}}}F=15|#default=0}}<noinclude>
+
{{#switch:{{padleft:|{{#expr:{{{2|0}}}+1}}|{{{1|}}}}}
 +
  |{{padleft:|{{{2|0}}}|{{{1|}}}}}0=0
 +
  |{{padleft:|{{{2|0}}}|{{{1|}}}}}1=1
 +
  |{{padleft:|{{{2|0}}}|{{{1|}}}}}2=2
 +
  |{{padleft:|{{{2|0}}}|{{{1|}}}}}3=3
 +
  |{{padleft:|{{{2|0}}}|{{{1|}}}}}4=4
 +
  |{{padleft:|{{{2|0}}}|{{{1|}}}}}5=5
 +
  |{{padleft:|{{{2|0}}}|{{{1|}}}}}6=6
 +
  |{{padleft:|{{{2|0}}}|{{{1|}}}}}7=7
 +
  |{{padleft:|{{{2|0}}}|{{{1|}}}}}8=8
 +
  |{{padleft:|{{{2|0}}}|{{{1|}}}}}9=9
 +
  |{{padleft:|{{{2|0}}}|{{{1|}}}}}A=10
 +
  |{{padleft:|{{{2|0}}}|{{{1|}}}}}B=11
 +
  |{{padleft:|{{{2|0}}}|{{{1|}}}}}C=12
 +
  |{{padleft:|{{{2|0}}}|{{{1|}}}}}D=13
 +
  |{{padleft:|{{{2|0}}}|{{{1|}}}}}E=14
 +
  |{{padleft:|{{{2|0}}}|{{{1|}}}}}F=15
 +
  |#default=0
 +
}}<noinclude>
 
{{documentation}}
 
{{documentation}}
 
</noinclude>
 
</noinclude>

Revision as of 08:16, 11 September 2010

0

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

This subtemplate of {{hex2dec}} converts a single character of a hex string into its decimal equivalent. This subtemplate is not meant to be called directly.

Usage

because on position 4 is value A and Ahex=10dec. Position count is from left, with the first position=0 (not 1).

This template works in conjunction with the following templates:

  • {{Hex2dec/main}}: does the actual multiplication and addition to create a decimal number.
  • {{Hex2dec/1}}: returns the length of the hexadecimal string.