Using hex in an array and "scanning" for it fails.
-
I am going nuts with this test code. Two dimensional array and my test objective is to find matching first element in the arrays. It works fine "scanning " for 0xA as it should , goes crazy when I try to look for 0xB0. I hope is is something stupid I am overlooking. Hope any extra pairs of eyes will spot the problem.
#define COMMAND_LIST 16
int8_t ILI9341_Command_List[][COMMAND_LIST] = {
{ 0 },
{ 1 },
{ 4 },
{ 6, 7 , 8 },
{7},
{0xA,8,9,10,11,12},
{0xB0,8,9,10,11,12},
{9}
};uint8_t ProcessCommand = 0xB0; // 0xA work fine 0xB0 fails
int index = 0;
do {
cout << "SCAN ProcessCommand " << hex << +ProcessCommand << "@ index "
<< dec << +index << endl;} while (ILI9341\_Command\_List\[index++\]\[0\] != ProcessCommand);
-
I am going nuts with this test code. Two dimensional array and my test objective is to find matching first element in the arrays. It works fine "scanning " for 0xA as it should , goes crazy when I try to look for 0xB0. I hope is is something stupid I am overlooking. Hope any extra pairs of eyes will spot the problem.
#define COMMAND_LIST 16
int8_t ILI9341_Command_List[][COMMAND_LIST] = {
{ 0 },
{ 1 },
{ 4 },
{ 6, 7 , 8 },
{7},
{0xA,8,9,10,11,12},
{0xB0,8,9,10,11,12},
{9}
};uint8_t ProcessCommand = 0xB0; // 0xA work fine 0xB0 fails
int index = 0;
do {
cout << "SCAN ProcessCommand " << hex << +ProcessCommand << "@ index "
<< dec << +index << endl;} while (ILI9341\_Command\_List\[index++\]\[0\] != ProcessCommand);
because 0xb0 is negative in 8 bits? You are comparing a
uint8_t
(unsigned) with anint8_t
(signed)Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
-
because 0xb0 is negative in 8 bits? You are comparing a
uint8_t
(unsigned) with anint8_t
(signed)Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012