I have this:
int serialInt = 40000359;
but what I really need is this:
int serialHex = (int)0x40000359;
What can I do to turn serialInt into serialHex?
I found some code that claimed to do this:
int IntToHex(int input)
{
std::stringstream ss;
for (int i=2*sizeof(int) - 1; i >= 0; i--)
{
ss << "0123456789ABCDEF"[((input >> i*4) & 0xF)];
}
int output;
ss >> output;
return output;
}
but the result is incorrect. The output of:
std::cout << "Correct: " << (int)0x000040000359 << std::endl;
int serial = 40000359;
int serialHex = IntToHex(serial);
std::cout << "Serial converted to hex: " << serialHex << std::endl;
is
Correct: 1073742681
Serial converted to hex: 2625
Any thoughts on a better way to do this?
Thanks,
David