<?xml version="1.0" encoding="windows-1252"?>
<node id="63225" title="Answer: How do I convert from decimal to hexidecimal?" created="2001-03-09 09:58:43" updated="2005-07-27 11:25:32">
<type id="1888">
categorized answer</type>
<author id="11732">
QandAEditors</author>
<data>
<field name="doctext">
Use the X, x and # format codes in printf and sprintf:
&lt;br&gt;
&lt;pre&gt;
    $num = 15;

    printf("%X\n",     $num);   # F
    printf("%x\n",     $num);   # f
    printf("%02x\n",   $num);   # 0f
    printf("%#x\n",    $num);   # 0xf
    printf("0x%02x\n", $num);   # 0x0f
&lt;/pre&gt;
The last example is excessive but it forces formatting for zero:
&lt;pre&gt;
    printf("%#x\n",    0);      # 0
    printf("0x%02x\n", 0);      # 0x00

&lt;/pre&gt;</field>
<field name="parent_node">
63074</field>
</data>
</node>
