Modèle:Dec-hex : Différence entre versions

De Minecraft Wiki
Aller à : navigation, rechercher
m (Annulation des modifications 50667 de Itouchmasterpro (discussion))
(Contenu remplacé par « <includeonly>{{#invoke: Convert base | fromDec | {{{1}}} | 16 }}</includeonly><noinclude> {{/doc}} Dec-hex en:Template:Decimal to hexadecima... »)
Ligne 1 : Ligne 1 :
<includeonly>{{#ifexpr: {{#len: {{{1|}}} }} < 9 | {{#ifexpr: {{#len: {{{1|}}} }} > 0 | {{
+
<includeonly>{{#invoke: Convert base | fromDec | {{{1}}} | 16 }}</includeonly><noinclude>
#ifexpr: {{#len: {{{1}}} }} > 0 | {{#vardefine:char1|{{#expr: {{{1}}} mod 16}}}} | {{ #vardefine:char1|0}} }}{{
 
#ifexpr: {{#len: {{{1}}} }} > 1 | {{#vardefine:char2|{{#expr: {{{1}}} / 16 mod 16}}}} | {{ #vardefine:char2|0}} }}{{
 
#ifexpr: {{#len: {{{1}}} }} > 2 | {{#vardefine:char3|{{#expr: {{{1}}} / 256 mod 16}}}} | {{ #vardefine:char3|0}} }}{{
 
#ifexpr: {{#len: {{{1}}} }} > 3 | {{#vardefine:char4|{{#expr: {{{1}}} / 4096 mod 16}}}} | {{ #vardefine:char4|0}} }}{{
 
#ifexpr: {{#len: {{{1}}} }} > 4 | {{#vardefine:char5|{{#expr: {{{1}}} / 65536 mod 16}}}} | {{ #vardefine:char5|0}} }}{{
 
#ifexpr: {{#len: {{{1}}} }} > 5 | {{#vardefine:char6|{{#expr: {{{1}}} / 1048576 mod 16}}}} | {{ #vardefine:char6|0}} }}{{
 
#ifexpr: {{#len: {{{1}}} }} > 6 | {{#vardefine:char7|{{#expr: {{{1}}} / 16777216 mod 16}}}} | {{ #vardefine:char7|0}} }}{{
 
#ifeq: {{#len: {{{1}}} }} | 8 | {{#vardefine:char8|{{#expr: {{{1}}} / 268435456 mod 16}}}} | {{ #vardefine:char8|0}} }}{{
 
 
#ifexpr: {{#var:char8|0}} > 0 | {{#switch: {{#var:char8}}
 
| 10 = A | 11 = B | 12 = C | 13 = D | 14 = E | 15 = F | {{#var:char8}}
 
}} }}{{#ifexpr: {{#var:char8|0}}{{#var:char7}} > 0 | {{
 
#switch: {{#var:char7}}
 
| 10 = A | 11 = B | 12 = C | 13 = D | 14 = E | 15 = F | {{#var:char7}}
 
}} }}{{#ifexpr: {{#var:char8|0}}{{#var:char7}}{{#var:char6}} > 0 | {{
 
#switch: {{#var:char6}}
 
| 10 = A | 11 = B | 12 = C | 13 = D | 14 = E | 15 = F | {{#var:char6}}
 
}} }}{{#ifexpr: {{#var:char8|0}}{{#var:char7}}{{#var:char6}}{{#var:char5}} > 0 | {{
 
#switch: {{#var:char5}}
 
| 10 = A | 11 = B | 12 = C | 13 = D | 14 = E | 15 = F | {{#var:char5}}
 
}} }}{{#ifexpr: {{#var:char8|0}}{{#var:char7}}{{#var:char6}}{{#var:char5}}{{#var:char4}} > 0 | {{
 
#switch: {{#var:char4}}
 
| 10 = A | 11 = B | 12 = C | 13 = D | 14 = E | 15 = F | {{#var:char4}}
 
}} }}{{#ifexpr: {{#var:char8|0}}{{#var:char7}}{{#var:char6}}{{#var:char5}}{{#var:char4}}{{#var:char3}} > 0 | {{
 
#switch: {{#var:char3}}
 
| 10 = A | 11 = B | 12 = C | 13 = D | 14 = E | 15 = F | {{#var:char3}}
 
}} }}{{#ifexpr: {{#var:char8|0}}{{#var:char7}}{{#var:char6}}{{#var:char5}}{{#var:char4}}{{#var:char3}}{{#var:char2}} > 0 | {{
 
#switch: {{#var:char2}}
 
| 10 = A | 11 = B | 12 = C | 13 = D | 14 = E | 15 = F | {{#var:char2}}
 
}} }}{{
 
#switch: {{#var:char1}}
 
| 10 = A | 11 = B | 12 = C | 13 = D | 14 = E | 15 = F | {{#var:char1}}
 
}} }} | <strong class="error">Chaîne trop longue.</strong> }}</includeonly><noinclude>
 
 
{{/doc}}
 
{{/doc}}
   

Version du 26 janvier 2014 à 22:29

Ceci est la page de documentation, elle devrait être incluse dans le page principale du modèle. Voir Modèle:Documentation pour plus d'informations

Ce modèle permet de convertir une valeur décimale en une valeur hexadécimale. La valeur hexadécimale est longue au maximum de 6 caractères, ce qui correspond à une valeur décimale maximale de 16 777 215.

Utilisation

{{Dec-hex|1234}} affichera : 4D2