# How to change number data from base 256 to base 16?

• 11-04-2002
How to change number data from base 256 to base 16?
If I have these below data (base 256)

Code:

```data[0] = 154; // 9A in base 16 data[1] = 203; // CB in base 16 data[2] = 15;  // 0F in base 16 data[3] = 54;  // 38in base 16 data[4] = 248; // F8 in base 16 data[5] = 175; // AF in base 16```
and I want to change data(base 256) to Ctring which have format in base 16 character

Code:

```CString m_data; m_data = "9ACB0F38F8AF";```
Do you know how to do that?
```// converting the integer stored in data[i] to the for AB in hex. int temp = data[i]; char first, second; int units = temp % 16; // Units now holds an integer 0 to 15, this is the B part temp = temp-units; temp = temp*0.1; temp = temp % 16; // Temp now holds an integer 0 to 15, this is the A part // Now convert the two integers to characters. switch(units) {  case 0: second = '0'; break;  case 1: second = '1'; break; // Other cases go in between  case 9: second = '9'; break;  case 10: second = 'A'; break; // More cases in here  case 15: second = 'F'; break; } switch(temp) {  // Same as before but into first. } cout<<data[i]<<" is "<<first<<second<<" in hex."; // Do some code to put first and second into your cstring.```