> You cannot simply typecast between two incompatible types!!! Have you heard
> of stol() or stod() or whatevet they're called... Can't remeber now, my
> mind is on /^perl$/o at the moment...

A little too much so, I think.  There are no invalid casts in Thomas's code.
Converting chars to doubles is just fine, as is converting doubles to long
integers.

-- Keith Rollin
-- Palm OS Emulator engineer






Igor Mozolevsky <[EMAIL PROTECTED]> on 01/30/2001 03:47:40 PM

Please respond to "Palm Developer Forum" <[EMAIL PROTECTED]>

Sent by:  Igor Mozolevsky <[EMAIL PROTECTED]>


To:   "Palm Developer Forum" <[EMAIL PROTECTED]>
cc:    (Keith Rollin/US/PALM)
Subject:  Re: GCC Compiler Bug? (Or am I just losing my mind?)



At 13:56 30/01/2001 -0500, you wrote:
>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.

You cannot simply typecast between two incompatible types!!! Have you heard
of stol() or stod() or whatevet they're called... Can't remeber now, my
mind is on /^perl$/o at the moment...


Igor M-)





-- 
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