title: How to convert BigInteger value to Hex in Java
body: <p>I have a BigInteger number and I need to convert it to Hexadecimal. I tried the following:</p>
  
  <pre><code>    String dec = null;
      System.out.println("Enter the value in Dec: ");
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      dec = br.readLine();  
      BigInteger toHex=new BigInteger(dec,16);
      String s=toHex.toString(16);
      System.out.println("The value in Hex is: "+ s);
  </code></pre>
  
  <p>But this does not give me the correct value after conversion. Can anybody help.</p>