Dec 4, 2012 at 10:49pm Dec 4, 2012 at 10:49pm UTC
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 Dec 4, 2012 at 10:50pm Dec 4, 2012 at 10:50pm UTC
Dec 4, 2012 at 10:58pm Dec 4, 2012 at 10:58pm UTC
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 Dec 4, 2012 at 11:03pm Dec 4, 2012 at 11:03pm UTC
Dec 4, 2012 at 11:00pm Dec 4, 2012 at 11:00pm UTC
hmm, maybe unsigned short?