Difference between revisions of "Hex"
From Sega Retro
Line 5: | Line 5: | ||
| {{#vardefine:hexoutput|{{#sub:{{#var:hexoutput}}|1}}}}{{incvar|i}} | | {{#vardefine:hexoutput|{{#sub:{{#var:hexoutput}}|1}}}}{{incvar|i}} | ||
}}{{ | }}{{ | ||
− | #ifexpr:{{#len:{{#var:hexoutput}}}}>4|{{#vardefine:pad|8}}}}{{RolloverText|1=<span style="font-family: monospace !important; font-weight:bold;"><span style="color:#999999; font-family: monospace !important;">{{padleft:|{{#expr:{{#var:pad}}-{{#len:{{#var:hexoutput}}}}}}|0}}</span>{{#var:hexoutput}}</span>|2=Hexadecimal}}{{clearvar|hexoutput|pad}}</includeonly><noinclude> | + | #ifexpr:{{#len:{{#var:hexoutput}}}}>4|{{#vardefine:pad|8}}}}{{#ifeq:{{#len:{{#var:hexoutput}}}}|0|{{#vardefine:hexoutput|0}}}}{{RolloverText|1=<span style="font-family: monospace !important; font-weight:bold;"><span style="color:#999999; font-family: monospace !important;">{{padleft:|{{#expr:{{#var:pad}}-{{#len:{{#var:hexoutput}}}}}}|0}}</span>{{#var:hexoutput}}</span>|2=Hexadecimal}}{{clearvar|hexoutput|pad}}</includeonly><noinclude> |
This template displays a hexadecimal value with the appropriate formatting. | This template displays a hexadecimal value with the appropriate formatting. | ||
Line 17: | Line 17: | ||
<tt><nowiki>{{hex|abcde}}</nowiki></tt> returns {{hex|abcde}}. | <tt><nowiki>{{hex|abcde}}</nowiki></tt> returns {{hex|abcde}}. | ||
− | <tt><nowiki>{{hex|$ | + | <tt><nowiki>{{hex|$00}}</nowiki></tt> returns {{hex|$00}}. |
[[Category:Templates]]</noinclude> | [[Category:Templates]]</noinclude> |
Revision as of 16:45, 24 April 2023
This template displays a hexadecimal value with the appropriate formatting.
Example
{{hex|0123}} returns 123.
{{hex|$78000}} returns 00078000.
{{hex|0x1800}} returns 1800.
{{hex|abcde}} returns 000ABCDE.
{{hex|$00}} returns 0.