Difference between revisions of "Template:Hex2dec/2"
Jump to navigation
Jump to search
imported>Plastikspork (rv for now) |
imported>Ludwigs2 |
||
| Line 1: | Line 1: | ||
| − | {{#switch | + | {{#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
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
{{hex2dec/2|0xFFADBDEC|4}}--> 10
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.
| The above documentation is transcluded from Template:Hex2dec/2/doc. (edit | history) Editors can experiment in this template's sandbox (edit | diff) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |