Difference between revisions of "Template:Dec2hex"

From blackwiki
Jump to navigation Jump to search
imported>Toohool
(Requesting speedy deletion (CSD T3). (TW))
imported>Dispenser
(Revert, this is an inverse for Template:Hex2dec if anyone needs it. Like needing to color flip a hex color valve.)
Line 1: Line 1:
<noinclude>{{db-duplicatetemplate|1=05:22, 24 February 2013 (UTC)|2=Hexadecimal}}</noinclude>
 
 
0x{{#switch:{{{digits|{{#expr:ceil(ln {{{1|0}}}/ln 16)}}}}}
 
0x{{#switch:{{{digits|{{#expr:ceil(ln {{{1|0}}}/ln 16)}}}}}
 
|1
 
|1

Revision as of 01:29, 1 March 2013

0x00

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

Usage

Works for all values in the range 0–4294967295.

  • {{dec2hex|0}} → 0x00
  • {{dec2hex|160}} → 0xA0
  • {{dec2hex|1984}} → 0x7C0
  • {{dec2hex|65535}} → 0xFFFF
  • {{dec2hex|8675309}} → 0x845FED
  • {{dec2hex|123456789}} → 0x75BCD15
  • {{dec2hex|3735928559}} → 0xDEADBEEF
  • {{dec2hex|4294967295}} → 0xFFFFFFFF
digits
Specify how many digits are show [2,8]. Example: {{dec2hex|65535|digits=8}} → 0x0000FFFF

See also