title: Within a windows batch file, how do I set an environment variable with the hexadecimal representation of a decimal number?
body: <p>When using the Windows set /p and set /a commands to accept a hexadecimal value from the command line and convert it to decimal. What I need is to be able to take a decimal value and set and environment variable with its hexadecimal equivalent.</p>
  
  <p>Current batch file coding:</p>
  
  <pre><code>@echo off
  set HexV1=%1
  set HexV2=%2
  set /A DecV1=0x%HexV1%
  set /A DecV2=0x%HexV2%
  set /A HexV3=0x%HexV1% + 0x1
  set /A HexV4=0x%Hexv2% + 0x2
  set Dec
  set Hex
  </code></pre>
  
  <p>Produces:</p>
  
  <pre><code>C:&gt;hexmath a f
  DecV1=10
  DecV2=15
  HexV1=a
  HexV2=f
  HexV3=11
  HexV4=17
  </code></pre>
  
  <p>What I need is to be able to set <code>HexV3</code> to b and <code>HexV4</code> to 11.</p>
  
  <p>Any suggestions?</p>