Hi,

I've found some very strange behavior in my code, and I've distilled the
problem down into these few lines of code:

   char         s[10];
   double       d;

   s[0] = '4';
   d = (double) (s[0] - '0');
   HostTraceOutputTL(appErrorClass, "Number is %ld", (Int32) d);

   StrCopy(s, "4");
   d = (double) (s[0] - '0');
   HostTraceOutputTL(appErrorClass, "Number is %ld", (Int32) d);

The output from these statements is:

   Number is 4
   Number is 0

How can the results be different? I've tried every kind of cast and
intermediate variable I could think of. Whether s is char or unsigned char
makes no difference either.

In my code, I need this to work for each character in a string. What do I
need to do to the code so that I can StrCopy a string into s and have it
work correctly?

(I ran this in POSE 3.0a8 using both the 3.0 and 3.5 ROMs on a Windows Me
machine. My GCC version says "gcc version egcs-2.91.57 19980901 (egcs-1.1
release)".)

Thanks!

Tom


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to