How to set the value 0xEB90 into 2 Bytes?

The site http://easycalculation.com/hex-converter.php converts the value EB90 to 60304 wich is also found with:

1
2
3
QString strStart = "EB90";
bool ok;
unsigned int startWord = strStart.toUInt(&ok, 16);

To store EB90 in 2 Bytes, one could do:

short x = startWord;

Now debugger says that the value of x is -5232.

What is the standart/correct way to put EB90 (0xEB90 or EB90H) into 2 Bytes?

Thanks in advance.
Last edited on
Your debugger is correct.
1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
#include <iomanip>

    using namespace std;

int main()
{
   short int a = 0xEB90;
   cout << "a = " << a << "  (dec)" << endl;
   cout << "a = " << hex << a << " (hex)" << endl;
   return 0;
}
a = -5232  (dec)
a = eb90 (hex)


If you use an unsigned short integer, the decimal value will be 60304, but that's merely a matter of how the value is interpreted, internally it is still stored as the same binary digits.
Last edited on
hmm, maybe unsigned short?
Topic archived. No new replies allowed.