long long giving unexpected results on hardware | developer.brewmp.com long long giving unexpected results on hardware | developer.brewmp.com

Developer

long long giving unexpected results on hardware

Forums:

If I run the following on hardware

	int anInt = 0xFF;
	DBGPRINTF("anInt: %x", anInt);
	char str[20];
	SNPRINTF(&str[0], 20, "%x", anInt);
	DBGPRINTF("str: %s", str);

Then the output viewed using the logger is ff, as we would expect. So far so good.

However if the following is run on hardware:

 

	long long aLongLong = 0xFF;
	DBGPRINTF("aLongLong: %x", aLongLong);
	SNPRINTF(&str[0], 20, "%x", aLongLong);
	DBGPRINTF("str: %s", str);

then the output is:

aLongLong: 102a7cfd

str: 10189359

 

Which is not what was expected (and 10189359 isn't even the decimal equivalent of 0x102a7cfd).

 

Its the same thing for unsigned long long also. What is the problem?

 

In case there was an issue with the logger, I displayed it to screen using the following code:

AECHAR format[4] = {'%', '1', '6', 'x'};
WSPRINTF(&szBuf[0], 64, format, aLongLong);
IDisplay_DrawText(.... szBuf...)

Then the screen displays 102296a1.

 

What is going on?

 

(everything seems fine on the simulator).

Can you name the device model name?  One more thing why are you assigning 8 bit value (0xFF) in long long(long long aLongLong = 0xFF;), i meant you can simply use int for this, anyways this is not going to effect current scenario.

Can you name the device model name?  One more thing why are you assigning 8 bit value (0xFF) in long long(long long aLongLong = 0xFF;), i meant you can simply use int for this, anyways this is not going to effect current scenario.

Its a Pantech CDM8992.
 
I'm using FF because its just example illustrative code. I noticed something strange going on with long longs while using larger numbers and used FF to see if also occurred with smaller ones. The pasted code was an experiement to see if this was the case, which it was.

Its a Pantech CDM8992.
 
I'm using FF because its just example illustrative code. I noticed something strange going on with long longs while using larger numbers and used FF to see if also occurred with smaller ones. The pasted code was an experiement to see if this was the case, which it was.

I checked on CDM8992, I tried with 32 bit number and it worked fine  got result FFFFFFFF in the logger, below are the logs from below code
 char str[20];
uint64 aLongLong = 0xFFFFFFFF;

 

SNPRINTF(str, 20, "%X", aLongLong);
DBGPRINTF(
"############hello");

DBGPRINTF(
"str: %s", str); 
08/29/11 15:34:28.922213 ############hello *myhelloworld.c 281 308/29/11 15:34:28.922265 str: FFFFFFFF *myhelloworld.c 282 3
device S/w build: D8992VWB745F.210, please flash your device with this build.

I checked on CDM8992, I tried with 32 bit number and it worked fine  got result FFFFFFFF in the logger, below are the logs from below code
 char str[20];
uint64 aLongLong = 0xFFFFFFFF;

 

SNPRINTF(str, 20, "%X", aLongLong);
DBGPRINTF(
"############hello");

DBGPRINTF(
"str: %s", str); 
08/29/11 15:34:28.922213 ############hello *myhelloworld.c 281 308/29/11 15:34:28.922265 str: FFFFFFFF *myhelloworld.c 282 3
device S/w build: D8992VWB745F.210, please flash your device with this build.